1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // duckdb/parser/expression/comparison_expression.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/parser/parsed_expression.hpp" |
12 | |
13 | namespace duckdb { |
14 | //! ComparisonExpression represents a boolean comparison (e.g. =, >=, <>). Always returns a boolean |
15 | //! and has two children. |
16 | class ComparisonExpression : public ParsedExpression { |
17 | public: |
18 | static constexpr const ExpressionClass TYPE = ExpressionClass::COMPARISON; |
19 | |
20 | public: |
21 | DUCKDB_API ComparisonExpression(ExpressionType type, unique_ptr<ParsedExpression> left, |
22 | unique_ptr<ParsedExpression> right); |
23 | |
24 | unique_ptr<ParsedExpression> left; |
25 | unique_ptr<ParsedExpression> right; |
26 | |
27 | public: |
28 | string ToString() const override; |
29 | |
30 | static bool Equal(const ComparisonExpression &a, const ComparisonExpression &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 | void FormatSerialize(FormatSerializer &serializer) const override; |
37 | static unique_ptr<ParsedExpression> FormatDeserialize(ExpressionType type, FormatDeserializer &deserializer); |
38 | |
39 | public: |
40 | template <class T, class BASE> |
41 | static string ToString(const T &entry) { |
42 | return StringUtil::Format("(%s %s %s)" , entry.left->ToString(), ExpressionTypeToOperator(entry.type), |
43 | entry.right->ToString()); |
44 | } |
45 | }; |
46 | } // namespace duckdb |
47 | |