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