1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/function/table_macro_function.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | //! The SelectStatement of the view |
9 | #include "duckdb/function/table_macro_function.hpp" |
10 | |
11 | #include "duckdb/parser/expression/constant_expression.hpp" |
12 | #include "duckdb/parser/query_node.hpp" |
13 | |
14 | namespace duckdb { |
15 | |
16 | TableMacroFunction::TableMacroFunction(unique_ptr<QueryNode> query_node) |
17 | : MacroFunction(MacroType::TABLE_MACRO), query_node(std::move(query_node)) { |
18 | } |
19 | |
20 | TableMacroFunction::TableMacroFunction(void) : MacroFunction(MacroType::TABLE_MACRO) { |
21 | } |
22 | |
23 | unique_ptr<MacroFunction> TableMacroFunction::Copy() const { |
24 | auto result = make_uniq<TableMacroFunction>(); |
25 | result->query_node = query_node->Copy(); |
26 | this->CopyProperties(other&: *result); |
27 | return std::move(result); |
28 | } |
29 | |
30 | string TableMacroFunction::ToSQL(const string &schema, const string &name) const { |
31 | return MacroFunction::ToSQL(schema, name) + StringUtil::Format(fmt_str: "TABLE (%s);", params: query_node->ToString()); |
32 | } |
33 | |
34 | void TableMacroFunction::SerializeInternal(FieldWriter &writer) const { |
35 | writer.WriteSerializable(element: *query_node); |
36 | } |
37 | |
38 | unique_ptr<MacroFunction> TableMacroFunction::Deserialize(FieldReader &reader) { |
39 | auto result = make_uniq<TableMacroFunction>(); |
40 | result->query_node = reader.ReadRequiredSerializable<QueryNode>(); |
41 | return std::move(result); |
42 | } |
43 | |
44 | } // namespace duckdb |
45 |