| 1 | #include "duckdb/planner/expression/bound_columnref_expression.hpp" |
| 2 | |
| 3 | #include "duckdb/common/types/hash.hpp" |
| 4 | |
| 5 | using namespace duckdb; |
| 6 | using namespace std; |
| 7 | |
| 8 | BoundColumnRefExpression::BoundColumnRefExpression(string alias, TypeId type, ColumnBinding binding, idx_t depth) |
| 9 | : Expression(ExpressionType::BOUND_COLUMN_REF, ExpressionClass::BOUND_COLUMN_REF, type), binding(binding), |
| 10 | depth(depth) { |
| 11 | this->alias = alias; |
| 12 | } |
| 13 | |
| 14 | BoundColumnRefExpression::BoundColumnRefExpression(TypeId type, ColumnBinding binding, idx_t depth) |
| 15 | : BoundColumnRefExpression(string(), type, binding, depth) { |
| 16 | } |
| 17 | |
| 18 | unique_ptr<Expression> BoundColumnRefExpression::Copy() { |
| 19 | return make_unique<BoundColumnRefExpression>(alias, return_type, binding, depth); |
| 20 | } |
| 21 | |
| 22 | hash_t BoundColumnRefExpression::Hash() const { |
| 23 | auto result = Expression::Hash(); |
| 24 | result = CombineHash(result, duckdb::Hash<uint64_t>(binding.column_index)); |
| 25 | result = CombineHash(result, duckdb::Hash<uint64_t>(binding.table_index)); |
| 26 | return CombineHash(result, duckdb::Hash<uint64_t>(depth)); |
| 27 | } |
| 28 | |
| 29 | bool BoundColumnRefExpression::Equals(const BaseExpression *other_) const { |
| 30 | if (!BaseExpression::Equals(other_)) { |
| 31 | return false; |
| 32 | } |
| 33 | auto other = (BoundColumnRefExpression *)other_; |
| 34 | return other->binding == binding && other->depth == depth; |
| 35 | } |
| 36 | |
| 37 | string BoundColumnRefExpression::ToString() const { |
| 38 | return "#[" + to_string(binding.table_index) + "." + to_string(binding.column_index) + "]" ; |
| 39 | } |
| 40 | |