1#include "duckdb/planner/operator/logical_simple.hpp"
2#include "duckdb/parser/parsed_data/alter_info.hpp"
3#include "duckdb/parser/parsed_data/attach_info.hpp"
4#include "duckdb/parser/parsed_data/drop_info.hpp"
5#include "duckdb/parser/parsed_data/load_info.hpp"
6#include "duckdb/parser/parsed_data/transaction_info.hpp"
7#include "duckdb/parser/parsed_data/vacuum_info.hpp"
8#include "duckdb/parser/parsed_data/detach_info.hpp"
9
10namespace duckdb {
11
12void LogicalSimple::Serialize(FieldWriter &writer) const {
13 writer.WriteField<LogicalOperatorType>(element: type);
14 switch (type) {
15 case LogicalOperatorType::LOGICAL_ALTER:
16 info->Cast<AlterInfo>().Serialize(serializer&: writer.GetSerializer());
17 break;
18 case LogicalOperatorType::LOGICAL_DROP:
19 info->Cast<DropInfo>().Serialize(serializer&: writer.GetSerializer());
20 break;
21 case LogicalOperatorType::LOGICAL_LOAD:
22 info->Cast<LoadInfo>().Serialize(serializer&: writer.GetSerializer());
23 break;
24 case LogicalOperatorType::LOGICAL_VACUUM:
25 info->Cast<VacuumInfo>().Serialize(serializer&: writer.GetSerializer());
26 break;
27 case LogicalOperatorType::LOGICAL_ATTACH:
28 info->Cast<AttachInfo>().Serialize(serializer&: writer.GetSerializer());
29 break;
30 case LogicalOperatorType::LOGICAL_DETACH:
31 info->Cast<DetachInfo>().Serialize(serializer&: writer.GetSerializer());
32 break;
33 case LogicalOperatorType::LOGICAL_TRANSACTION:
34 info->Cast<TransactionInfo>().Serialize(serializer&: writer.GetSerializer());
35 break;
36 default:
37 throw InternalException(LogicalOperatorToString(type));
38 }
39}
40
41unique_ptr<LogicalOperator> LogicalSimple::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
42 auto type = reader.ReadRequired<LogicalOperatorType>();
43 unique_ptr<ParseInfo> parse_info;
44 switch (type) {
45 case LogicalOperatorType::LOGICAL_ALTER:
46 parse_info = AlterInfo::Deserialize(source&: reader.GetSource());
47 break;
48 case LogicalOperatorType::LOGICAL_DROP:
49 parse_info = DropInfo::Deserialize(deserializer&: reader.GetSource());
50 break;
51 case LogicalOperatorType::LOGICAL_LOAD:
52 parse_info = LoadInfo::Deserialize(deserializer&: reader.GetSource());
53 break;
54 case LogicalOperatorType::LOGICAL_VACUUM:
55 parse_info = VacuumInfo::Deserialize(deserializer&: reader.GetSource());
56 break;
57 case LogicalOperatorType::LOGICAL_ATTACH:
58 parse_info = AttachInfo::Deserialize(deserializer&: reader.GetSource());
59 break;
60 case LogicalOperatorType::LOGICAL_DETACH:
61 parse_info = DetachInfo::Deserialize(deserializer&: reader.GetSource());
62 break;
63 case LogicalOperatorType::LOGICAL_TRANSACTION:
64 parse_info = TransactionInfo::Deserialize(deserializer&: reader.GetSource());
65 break;
66 default:
67 throw InternalException(LogicalOperatorToString(type: state.type));
68 }
69 return make_uniq<LogicalSimple>(args&: type, args: std::move(parse_info));
70}
71
72idx_t LogicalSimple::EstimateCardinality(ClientContext &context) {
73 return 1;
74}
75
76} // namespace duckdb
77