/src/duckdb/src/planner/expression_binder/constant_binder.cpp
Line | Count | Source |
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 | 162 | : ExpressionBinder(binder, context), clause(std::move(clause)) { |
8 | 162 | } |
9 | | |
10 | 163 | BindResult ConstantBinder::BindExpression(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth, bool root_expression) { |
11 | 163 | auto &expr = *expr_ptr; |
12 | 163 | switch (expr.GetExpressionClass()) { |
13 | 0 | case ExpressionClass::COLUMN_REF: { |
14 | 0 | auto &colref = expr.Cast<ColumnRefExpression>(); |
15 | 0 | if (!colref.IsQualified()) { |
16 | 0 | auto value_function = GetSQLValueFunction(colref.GetColumnName()); |
17 | 0 | if (value_function) { |
18 | 0 | expr_ptr = std::move(value_function); |
19 | 0 | return BindExpression(expr_ptr, depth, root_expression); |
20 | 0 | } |
21 | 0 | } |
22 | 0 | throw BinderException::Unsupported(expr, clause + " cannot contain column names"); |
23 | 0 | } |
24 | 0 | case ExpressionClass::SUBQUERY: |
25 | 0 | throw BinderException(clause + " cannot contain subqueries"); |
26 | 0 | case ExpressionClass::DEFAULT: |
27 | 0 | return BindUnsupportedExpression(expr, depth, clause + " cannot contain DEFAULT clause"); |
28 | 0 | case ExpressionClass::WINDOW: |
29 | 0 | return BindUnsupportedExpression(expr, depth, clause + " cannot contain window functions!"); |
30 | 163 | default: |
31 | 163 | return ExpressionBinder::BindExpression(expr_ptr, depth); |
32 | 163 | } |
33 | 163 | } |
34 | | |
35 | 0 | string ConstantBinder::UnsupportedAggregateMessage() { |
36 | 0 | return clause + " cannot contain aggregates!"; |
37 | 0 | } |
38 | | |
39 | | } // namespace duckdb |