1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/expression/bound_case_expression.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/planner/expression.hpp"
12
13namespace duckdb {
14
15struct BoundCaseCheck {
16 unique_ptr<Expression> when_expr;
17 unique_ptr<Expression> then_expr;
18
19 void Serialize(Serializer &serializer) const;
20 static BoundCaseCheck Deserialize(Deserializer &source, PlanDeserializationState &state);
21};
22
23class BoundCaseExpression : public Expression {
24public:
25 static constexpr const ExpressionClass TYPE = ExpressionClass::BOUND_CASE;
26
27public:
28 BoundCaseExpression(LogicalType type);
29 BoundCaseExpression(unique_ptr<Expression> when_expr, unique_ptr<Expression> then_expr,
30 unique_ptr<Expression> else_expr);
31
32 vector<BoundCaseCheck> case_checks;
33 unique_ptr<Expression> else_expr;
34
35public:
36 string ToString() const override;
37
38 bool Equals(const BaseExpression &other) const override;
39
40 unique_ptr<Expression> Copy() override;
41
42 void Serialize(FieldWriter &writer) const override;
43 static unique_ptr<Expression> Deserialize(ExpressionDeserializationState &state, FieldReader &reader);
44};
45} // namespace duckdb
46