1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/parser/expression/columnref_expression.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/parser/parsed_expression.hpp"
12#include "duckdb/common/vector.hpp"
13
14namespace duckdb {
15
16//! Represents a reference to a column from either the FROM clause or from an
17//! alias
18class ColumnRefExpression : public ParsedExpression {
19public:
20 static constexpr const ExpressionClass TYPE = ExpressionClass::COLUMN_REF;
21
22public:
23 //! Specify both the column and table name
24 ColumnRefExpression(string column_name, string table_name);
25 //! Only specify the column name, the table name will be derived later
26 explicit ColumnRefExpression(string column_name);
27 //! Specify a set of names
28 explicit ColumnRefExpression(vector<string> column_names);
29
30 //! The stack of names in order of which they appear (column_names[0].column_names[1].column_names[2]....)
31 vector<string> column_names;
32
33public:
34 bool IsQualified() const;
35 const string &GetColumnName() const;
36 const string &GetTableName() const;
37 bool IsScalar() const override {
38 return false;
39 }
40
41 string GetName() const override;
42 string ToString() const override;
43
44 static bool Equal(const ColumnRefExpression &a, const ColumnRefExpression &b);
45 hash_t Hash() const override;
46
47 unique_ptr<ParsedExpression> Copy() const override;
48
49 void Serialize(FieldWriter &writer) const override;
50 static unique_ptr<ParsedExpression> Deserialize(ExpressionType type, FieldReader &source);
51 void FormatSerialize(FormatSerializer &serializer) const override;
52 static unique_ptr<ParsedExpression> FormatDeserialize(ExpressionType type, FormatDeserializer &deserializer);
53};
54} // namespace duckdb
55