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
14namespace duckdb {
15
16TableMacroFunction::TableMacroFunction(unique_ptr<QueryNode> query_node)
17 : MacroFunction(MacroType::TABLE_MACRO), query_node(std::move(query_node)) {
18}
19
20TableMacroFunction::TableMacroFunction(void) : MacroFunction(MacroType::TABLE_MACRO) {
21}
22
23unique_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
30string 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
34void TableMacroFunction::SerializeInternal(FieldWriter &writer) const {
35 writer.WriteSerializable(element: *query_node);
36}
37
38unique_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