| 1 | #include "duckdb/parser/expression/columnref_expression.hpp" |
|---|---|
| 2 | #include "duckdb/planner/binder.hpp" |
| 3 | #include "duckdb/planner/expression/bound_columnref_expression.hpp" |
| 4 | #include "duckdb/planner/expression_binder.hpp" |
| 5 | #include "duckdb/common/string_util.hpp" |
| 6 | |
| 7 | using namespace duckdb; |
| 8 | using namespace std; |
| 9 | |
| 10 | BindResult ExpressionBinder::BindExpression(ColumnRefExpression &colref, idx_t depth) { |
| 11 | assert(!colref.column_name.empty()); |
| 12 | // individual column reference |
| 13 | // resolve to either a base table or a subquery expression |
| 14 | if (colref.table_name.empty()) { |
| 15 | // no table name: find a binding that contains this |
| 16 | colref.table_name = binder.bind_context.GetMatchingBinding(colref.column_name); |
| 17 | if (colref.table_name.empty()) { |
| 18 | return BindResult( |
| 19 | StringUtil::Format("Referenced column \"%s\" not found in FROM clause!", colref.column_name.c_str())); |
| 20 | } |
| 21 | } |
| 22 | BindResult result = binder.bind_context.BindColumn(colref, depth); |
| 23 | if (!result.HasError()) { |
| 24 | bound_columns = true; |
| 25 | } |
| 26 | return result; |
| 27 | } |
| 28 |