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