1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/parser/expression/between_expression.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/parser/parsed_expression.hpp"
12
13namespace duckdb {
14
15class BetweenExpression : public ParsedExpression {
16public:
17 static constexpr const ExpressionClass TYPE = ExpressionClass::BETWEEN;
18
19public:
20 DUCKDB_API BetweenExpression(unique_ptr<ParsedExpression> input, unique_ptr<ParsedExpression> lower,
21 unique_ptr<ParsedExpression> upper);
22
23 unique_ptr<ParsedExpression> input;
24 unique_ptr<ParsedExpression> lower;
25 unique_ptr<ParsedExpression> upper;
26
27public:
28 string ToString() const override;
29
30 static bool Equal(const BetweenExpression &a, const BetweenExpression &b);
31
32 unique_ptr<ParsedExpression> Copy() const override;
33
34 void Serialize(FieldWriter &writer) const override;
35 static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
36
37 void FormatSerialize(FormatSerializer &serializer) const override;
38 static unique_ptr<ParsedExpression> FormatDeserialize(ExpressionType type, FormatDeserializer &deserializer);
39
40public:
41 template <class T, class BASE>
42 static string ToString(const T &entry) {
43 return "(" + entry.input->ToString() + " BETWEEN " + entry.lower->ToString() + " AND " +
44 entry.upper->ToString() + ")";
45 }
46};
47} // namespace duckdb
48