1 | #include "duckdb/planner/expression_binder/constant_binder.hpp" |
---|---|
2 | #include "duckdb/parser/expression/columnref_expression.hpp" |
3 | |
4 | namespace duckdb { |
5 | |
6 | ConstantBinder::ConstantBinder(Binder &binder, ClientContext &context, string clause) |
7 | : ExpressionBinder(binder, context), clause(std::move(clause)) { |
8 | } |
9 | |
10 | BindResult ConstantBinder::BindExpression(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth, bool root_expression) { |
11 | auto &expr = *expr_ptr; |
12 | switch (expr.GetExpressionClass()) { |
13 | case ExpressionClass::COLUMN_REF: { |
14 | auto &colref = expr.Cast<ColumnRefExpression>(); |
15 | if (!colref.IsQualified()) { |
16 | auto value_function = GetSQLValueFunction(column_name: colref.GetColumnName()); |
17 | if (value_function) { |
18 | expr_ptr = std::move(value_function); |
19 | return BindExpression(expr_ptr, depth, root_expression); |
20 | } |
21 | } |
22 | return BindResult(clause + " cannot contain column names"); |
23 | } |
24 | case ExpressionClass::SUBQUERY: |
25 | throw BinderException(clause + " cannot contain subqueries"); |
26 | case ExpressionClass::DEFAULT: |
27 | return BindResult(clause + " cannot contain DEFAULT clause"); |
28 | case ExpressionClass::WINDOW: |
29 | return BindResult(clause + " cannot contain window functions!"); |
30 | default: |
31 | return ExpressionBinder::BindExpression(expr_ptr, depth); |
32 | } |
33 | } |
34 | |
35 | string ConstantBinder::UnsupportedAggregateMessage() { |
36 | return clause + " cannot contain aggregates!"; |
37 | } |
38 | |
39 | } // namespace duckdb |
40 |