1#include "duckdb/parser/tableref.hpp"
2
3#include "duckdb/common/printer.hpp"
4#include "duckdb/common/serializer.hpp"
5#include "duckdb/parser/tableref/list.hpp"
6
7using namespace duckdb;
8using namespace std;
9
10void TableRef::Serialize(Serializer &serializer) {
11 serializer.Write<TableReferenceType>(type);
12 serializer.WriteString(alias);
13}
14
15//! Deserializes a blob back into an TableRef
16unique_ptr<TableRef> TableRef::Deserialize(Deserializer &source) {
17 auto type = source.Read<TableReferenceType>();
18 auto alias = source.Read<string>();
19 unique_ptr<TableRef> result;
20 switch (type) {
21 case TableReferenceType::BASE_TABLE:
22 result = BaseTableRef::Deserialize(source);
23 break;
24 case TableReferenceType::CROSS_PRODUCT:
25 result = CrossProductRef::Deserialize(source);
26 break;
27 case TableReferenceType::JOIN:
28 result = JoinRef::Deserialize(source);
29 break;
30 case TableReferenceType::SUBQUERY:
31 result = SubqueryRef::Deserialize(source);
32 break;
33 case TableReferenceType::TABLE_FUNCTION:
34 result = TableFunctionRef::Deserialize(source);
35 break;
36 case TableReferenceType::EMPTY:
37 result = EmptyTableRef::Deserialize(source);
38 break;
39 case TableReferenceType::EXPRESSION_LIST:
40 result = ExpressionListRef::Deserialize(source);
41 break;
42 case TableReferenceType::CTE:
43 case TableReferenceType::INVALID:
44 return nullptr;
45 }
46 result->alias = alias;
47 return result;
48}
49
50void TableRef::Print() {
51 Printer::Print(ToString());
52}
53