duckdb 0.7.2-dev3515.0 → 0.7.2-dev3546.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/configure.py +2 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/json/json_functions/read_json.cpp +1 -0
  4. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +42 -0
  5. package/src/duckdb/src/catalog/catalog_search_path.cpp +5 -0
  6. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  7. package/src/duckdb/src/common/constants.cpp +1 -0
  8. package/src/duckdb/src/common/types/vector.cpp +3 -3
  9. package/src/duckdb/src/common/types/vector_buffer.cpp +11 -3
  10. package/src/duckdb/src/common/types/vector_cache.cpp +5 -5
  11. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -2
  12. package/src/duckdb/src/function/macro_function.cpp +43 -0
  13. package/src/duckdb/src/function/scalar/strftime_format.cpp +1 -0
  14. package/src/duckdb/src/function/scalar_macro_function.cpp +10 -0
  15. package/src/duckdb/src/function/table/copy_csv.cpp +2 -6
  16. package/src/duckdb/src/function/table/read_csv.cpp +17 -0
  17. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  18. package/src/duckdb/src/function/table_macro_function.cpp +10 -0
  19. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -1
  20. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +0 -6
  21. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +0 -6
  22. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -0
  23. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +3 -3
  24. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +12 -2
  25. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +1 -2
  26. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +1 -1
  27. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +7 -1
  28. package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +3 -4
  29. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +7 -2
  30. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +5 -0
  31. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +4 -7
  32. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +8 -12
  33. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +6 -20
  34. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +6 -18
  35. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +4 -8
  36. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +4 -38
  37. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +5 -2
  38. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -10
  39. package/src/duckdb/src/parser/parsed_data/attach_info.cpp +42 -0
  40. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +0 -7
  41. package/src/duckdb/src/parser/parsed_data/create_info.cpp +19 -8
  42. package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +46 -0
  43. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +56 -0
  44. package/src/duckdb/src/parser/parsed_data/create_type_info.cpp +47 -0
  45. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +34 -0
  46. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +46 -0
  47. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +24 -0
  48. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +37 -0
  49. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +27 -9
  50. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
  51. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -0
  52. package/src/duckdb/src/planner/logical_operator.cpp +1 -2
  53. package/src/duckdb/src/planner/operator/logical_create_index.cpp +16 -25
  54. package/src/duckdb/src/planner/operator/logical_insert.cpp +30 -0
  55. package/src/duckdb/src/planner/operator/logical_simple.cpp +33 -5
  56. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +6 -16
  57. package/src/duckdb/src/planner/planner.cpp +4 -13
  58. package/src/duckdb/src/storage/checkpoint_manager.cpp +12 -6
  59. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  60. package/src/duckdb/ub_src_catalog_catalog_entry.cpp +1 -1
  61. package/src/duckdb/ub_src_parser_parsed_data.cpp +16 -0
  62. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +0 -104
package/configure.py CHANGED
@@ -63,6 +63,8 @@ elif 'DUCKDB_NODE_BINDIR' in os.environ:
63
63
  cflags += ['-g']
64
64
  if '-O0' in os.environ['DUCKDB_NODE_CFLAGS']:
65
65
  cflags += ['-O0']
66
+ if '-DNDEBUG' in os.environ['DUCKDB_NODE_CFLAGS']:
67
+ defines += ['NDEBUG']
66
68
 
67
69
  if 'DUCKDB_NODE_BUILD_CACHE' in os.environ:
68
70
  cache = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.2-dev3515.0",
5
+ "version": "0.7.2-dev3546.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -276,6 +276,7 @@ static void ReadJSONFunction(ClientContext &context, TableFunctionInput &data_p,
276
276
  TableFunction JSONFunctions::GetReadJSONTableFunction(shared_ptr<JSONScanInfo> function_info) {
277
277
  TableFunction table_function({LogicalType::VARCHAR}, ReadJSONFunction, ReadJSONBind,
278
278
  JSONGlobalTableFunctionState::Init, JSONLocalTableFunctionState::Init);
279
+ table_function.name = "read_json";
279
280
 
280
281
  JSONScan::TableFunctionDefaults(table_function);
281
282
  table_function.named_parameters["columns"] = LogicalType::ANY;
@@ -0,0 +1,42 @@
1
+ #include "duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp"
2
+ #include "duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp"
3
+ #include "duckdb/common/field_writer.hpp"
4
+ #include "duckdb/function/scalar_macro_function.hpp"
5
+
6
+ namespace duckdb {
7
+
8
+ MacroCatalogEntry::MacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info)
9
+ : FunctionEntry(
10
+ (info.function->type == MacroType::SCALAR_MACRO ? CatalogType::MACRO_ENTRY : CatalogType::TABLE_MACRO_ENTRY),
11
+ catalog, schema, info),
12
+ function(std::move(info.function)) {
13
+ this->temporary = info.temporary;
14
+ this->internal = info.internal;
15
+ }
16
+
17
+ ScalarMacroCatalogEntry::ScalarMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info)
18
+ : MacroCatalogEntry(catalog, schema, info) {
19
+ }
20
+
21
+ TableMacroCatalogEntry::TableMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info)
22
+ : MacroCatalogEntry(catalog, schema, info) {
23
+ }
24
+
25
+ unique_ptr<CreateMacroInfo> MacroCatalogEntry::GetInfoForSerialization() const {
26
+ auto info = make_uniq<CreateMacroInfo>(type);
27
+ info->catalog = catalog.GetName();
28
+ info->schema = schema.name;
29
+ info->name = name;
30
+ info->function = function->Copy();
31
+ return info;
32
+ }
33
+ void MacroCatalogEntry::Serialize(Serializer &serializer) const {
34
+ auto info = GetInfoForSerialization();
35
+ info->Serialize(serializer);
36
+ }
37
+
38
+ unique_ptr<CreateMacroInfo> MacroCatalogEntry::Deserialize(Deserializer &main_source, ClientContext &context) {
39
+ return unique_ptr_cast<CreateInfo, CreateMacroInfo>(CreateInfo::Deserialize(main_source));
40
+ }
41
+
42
+ } // namespace duckdb
@@ -145,6 +145,11 @@ void CatalogSearchPath::Set(vector<CatalogSearchEntry> new_paths, bool is_set_sc
145
145
  is_set_schema ? "schema" : "search_path", path.ToString());
146
146
  }
147
147
  }
148
+ if (is_set_schema) {
149
+ if (new_paths[0].catalog == TEMP_CATALOG || new_paths[0].catalog == SYSTEM_CATALOG) {
150
+ throw CatalogException("SET schema cannot be set to internal schema \"%s\"", new_paths[0].catalog);
151
+ }
152
+ }
148
153
  this->set_paths = std::move(new_paths);
149
154
  SetPaths(set_paths);
150
155
  }
@@ -84,7 +84,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
84
84
  throw InternalException("Attempting to create temporary entry \"%s\" in non-temporary catalog", name);
85
85
  }
86
86
  if (!value->temporary && catalog.IsTemporaryCatalog() && name != DEFAULT_SCHEMA) {
87
- throw InternalException("Attempting to create non-temporary entry \"%s\" in temporary catalog", name);
87
+ throw InvalidInputException("Cannot create non-temporary entry \"%s\" in temporary catalog", name);
88
88
  }
89
89
  }
90
90
  // lock the catalog for writing
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include "duckdb/common/limits.hpp"
4
4
  #include "duckdb/common/vector_size.hpp"
5
+ #include "duckdb/common/serializer.hpp"
5
6
 
6
7
  namespace duckdb {
7
8
 
@@ -1868,7 +1868,7 @@ idx_t ListVector::GetListSize(const Vector &vec) {
1868
1868
  return ListVector::GetListSize(child);
1869
1869
  }
1870
1870
  D_ASSERT(vec.auxiliary);
1871
- return ((VectorListBuffer &)*vec.auxiliary).size;
1871
+ return ((VectorListBuffer &)*vec.auxiliary).GetSize();
1872
1872
  }
1873
1873
 
1874
1874
  idx_t ListVector::GetListCapacity(const Vector &vec) {
@@ -1877,7 +1877,7 @@ idx_t ListVector::GetListCapacity(const Vector &vec) {
1877
1877
  return ListVector::GetListSize(child);
1878
1878
  }
1879
1879
  D_ASSERT(vec.auxiliary);
1880
- return ((VectorListBuffer &)*vec.auxiliary).capacity;
1880
+ return ((VectorListBuffer &)*vec.auxiliary).GetCapacity();
1881
1881
  }
1882
1882
 
1883
1883
  void ListVector::ReferenceEntry(Vector &vector, Vector &other) {
@@ -1894,7 +1894,7 @@ void ListVector::SetListSize(Vector &vec, idx_t size) {
1894
1894
  auto &child = DictionaryVector::Child(vec);
1895
1895
  ListVector::SetListSize(child, size);
1896
1896
  }
1897
- ((VectorListBuffer &)*vec.auxiliary).size = size;
1897
+ ((VectorListBuffer &)*vec.auxiliary).SetSize(size);
1898
1898
  }
1899
1899
 
1900
1900
  void ListVector::Append(Vector &target, const Vector &source, idx_t source_size, idx_t source_offset) {
@@ -58,12 +58,12 @@ VectorStructBuffer::~VectorStructBuffer() {
58
58
  }
59
59
 
60
60
  VectorListBuffer::VectorListBuffer(unique_ptr<Vector> vector, idx_t initial_capacity)
61
- : VectorBuffer(VectorBufferType::LIST_BUFFER), capacity(initial_capacity), child(std::move(vector)) {
61
+ : VectorBuffer(VectorBufferType::LIST_BUFFER), child(std::move(vector)), capacity(initial_capacity) {
62
62
  }
63
63
 
64
64
  VectorListBuffer::VectorListBuffer(const LogicalType &list_type, idx_t initial_capacity)
65
- : VectorBuffer(VectorBufferType::LIST_BUFFER), capacity(initial_capacity),
66
- child(make_uniq<Vector>(ListType::GetChildType(list_type), initial_capacity)) {
65
+ : VectorBuffer(VectorBufferType::LIST_BUFFER),
66
+ child(make_uniq<Vector>(ListType::GetChildType(list_type), initial_capacity)), capacity(initial_capacity) {
67
67
  }
68
68
 
69
69
  void VectorListBuffer::Reserve(idx_t to_reserve) {
@@ -96,6 +96,14 @@ void VectorListBuffer::PushBack(const Value &insert) {
96
96
  child->SetValue(size++, insert);
97
97
  }
98
98
 
99
+ void VectorListBuffer::SetCapacity(idx_t new_capacity) {
100
+ this->capacity = new_capacity;
101
+ }
102
+
103
+ void VectorListBuffer::SetSize(idx_t new_size) {
104
+ this->size = new_size;
105
+ }
106
+
99
107
  VectorListBuffer::~VectorListBuffer() {
100
108
  }
101
109
 
@@ -16,7 +16,7 @@ public:
16
16
  owned_data = allocator.Allocate(capacity * GetTypeIdSize(internal_type));
17
17
  // child data of the list
18
18
  auto &child_type = ListType::GetChildType(type);
19
- child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type));
19
+ child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type, capacity));
20
20
  auto child_vector = make_uniq<Vector>(child_type, false, false);
21
21
  auxiliary = make_shared<VectorListBuffer>(std::move(child_vector));
22
22
  break;
@@ -24,7 +24,7 @@ public:
24
24
  case PhysicalType::STRUCT: {
25
25
  auto &child_types = StructType::GetChildTypes(type);
26
26
  for (auto &child_type : child_types) {
27
- child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type.second));
27
+ child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type.second, capacity));
28
28
  }
29
29
  auto struct_buffer = make_shared<VectorStructBuffer>(type);
30
30
  auxiliary = std::move(struct_buffer);
@@ -48,13 +48,13 @@ public:
48
48
  // reinitialize the VectorListBuffer
49
49
  AssignSharedPointer(result.auxiliary, auxiliary);
50
50
  // propagate through child
51
+ auto &child_cache = (VectorCacheBuffer &)*child_caches[0];
51
52
  auto &list_buffer = (VectorListBuffer &)*result.auxiliary;
52
- list_buffer.capacity = capacity;
53
- list_buffer.size = 0;
53
+ list_buffer.SetCapacity(child_cache.capacity);
54
+ list_buffer.SetSize(0);
54
55
  list_buffer.SetAuxiliaryData(nullptr);
55
56
 
56
57
  auto &list_child = list_buffer.GetChild();
57
- auto &child_cache = (VectorCacheBuffer &)*child_caches[0];
58
58
  child_cache.ResetFromCache(list_child, child_caches[0]);
59
59
  break;
60
60
  }
@@ -7,9 +7,9 @@
7
7
 
8
8
  namespace duckdb {
9
9
 
10
- PhysicalCreateType::PhysicalCreateType(unique_ptr<CreateTypeInfo> info, idx_t estimated_cardinality)
10
+ PhysicalCreateType::PhysicalCreateType(unique_ptr<CreateTypeInfo> info_p, idx_t estimated_cardinality)
11
11
  : PhysicalOperator(PhysicalOperatorType::CREATE_TYPE, {LogicalType::BIGINT}, estimated_cardinality),
12
- info(std::move(info)) {
12
+ info(std::move(info_p)) {
13
13
  }
14
14
 
15
15
  //===--------------------------------------------------------------------===//
@@ -5,6 +5,7 @@
5
5
  #include "duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp"
6
6
  #include "duckdb/common/string_util.hpp"
7
7
  #include "duckdb/function/scalar_macro_function.hpp"
8
+ #include "duckdb/function/table_macro_function.hpp"
8
9
  #include "duckdb/parser/expression/columnref_expression.hpp"
9
10
  #include "duckdb/parser/expression/comparison_expression.hpp"
10
11
  #include "duckdb/parser/expression/function_expression.hpp"
@@ -91,4 +92,46 @@ string MacroFunction::ToSQL(const string &schema, const string &name) const {
91
92
  return StringUtil::Format("CREATE MACRO %s.%s(%s) AS ", schema, name, StringUtil::Join(param_strings, ", "));
92
93
  }
93
94
 
95
+ void MacroFunction::Serialize(Serializer &main_serializer) const {
96
+ FieldWriter writer(main_serializer);
97
+ writer.WriteField(type);
98
+ writer.WriteSerializableList(parameters);
99
+ writer.WriteField<uint32_t>((uint32_t)default_parameters.size());
100
+ auto &serializer = writer.GetSerializer();
101
+ for (auto &kv : default_parameters) {
102
+ serializer.WriteString(kv.first);
103
+ kv.second->Serialize(serializer);
104
+ }
105
+ SerializeInternal(writer);
106
+ writer.Finalize();
107
+ }
108
+
109
+ unique_ptr<MacroFunction> MacroFunction::Deserialize(Deserializer &main_source) {
110
+ FieldReader reader(main_source);
111
+ auto type = reader.ReadRequired<MacroType>();
112
+ auto parameters = reader.ReadRequiredSerializableList<ParsedExpression>();
113
+ auto default_param_count = reader.ReadRequired<uint32_t>();
114
+ unordered_map<string, unique_ptr<ParsedExpression>> default_parameters;
115
+ auto &source = reader.GetSource();
116
+ for (idx_t i = 0; i < default_param_count; i++) {
117
+ auto name = source.Read<string>();
118
+ default_parameters[name] = ParsedExpression::Deserialize(source);
119
+ }
120
+ unique_ptr<MacroFunction> result;
121
+ switch (type) {
122
+ case MacroType::SCALAR_MACRO:
123
+ result = ScalarMacroFunction::Deserialize(reader);
124
+ break;
125
+ case MacroType::TABLE_MACRO:
126
+ result = TableMacroFunction::Deserialize(reader);
127
+ break;
128
+ default:
129
+ throw InternalException("Cannot deserialize macro type");
130
+ }
131
+ result->parameters = std::move(parameters);
132
+ result->default_parameters = std::move(default_parameters);
133
+ reader.Finalize();
134
+ return result;
135
+ }
136
+
94
137
  } // namespace duckdb
@@ -417,6 +417,7 @@ string StrTimeFormat::ParseFormatSpecifier(const string &format_string, StrTimeF
417
417
  if (format_string.empty()) {
418
418
  return "Empty format string";
419
419
  }
420
+ format.format_specifier = format_string;
420
421
  format.specifiers.clear();
421
422
  format.literals.clear();
422
423
  format.numeric_width.clear();
@@ -49,4 +49,14 @@ string ScalarMacroFunction::ToSQL(const string &schema, const string &name) cons
49
49
  return MacroFunction::ToSQL(schema, name) + StringUtil::Format("(%s);", expression_copy->ToString());
50
50
  }
51
51
 
52
+ void ScalarMacroFunction::SerializeInternal(FieldWriter &writer) const {
53
+ writer.WriteSerializable(*expression);
54
+ }
55
+
56
+ unique_ptr<MacroFunction> ScalarMacroFunction::Deserialize(FieldReader &reader) {
57
+ auto result = make_uniq<ScalarMacroFunction>();
58
+ result->expression = reader.ReadRequiredSerializable<ParsedExpression>();
59
+ return std::move(result);
60
+ }
61
+
52
62
  } // namespace duckdb
@@ -324,15 +324,11 @@ static void WriteCSVChunkInternal(ClientContext &context, FunctionData &bind_dat
324
324
  csv_data.options.write_date_format[LogicalTypeId::DATE].ConvertDateVector(
325
325
  input.data[col_idx], cast_chunk.data[col_idx], input.size());
326
326
  } else if (options.has_format[LogicalTypeId::TIMESTAMP] &&
327
- csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP) {
327
+ (csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP ||
328
+ csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP_TZ)) {
328
329
  // use the timestamp format to cast the chunk
329
330
  csv_data.options.write_date_format[LogicalTypeId::TIMESTAMP].ConvertTimestampVector(
330
331
  input.data[col_idx], cast_chunk.data[col_idx], input.size());
331
- } else if (options.has_format[LogicalTypeId::TIMESTAMP_TZ] &&
332
- csv_data.sql_types[col_idx].id() == LogicalTypeId::TIMESTAMP_TZ) {
333
- // use the timestamp format to cast the chunk
334
- csv_data.options.write_date_format[LogicalTypeId::TIMESTAMP_TZ].ConvertTimestampVector(
335
- input.data[col_idx], cast_chunk.data[col_idx], input.size());
336
332
  } else {
337
333
  // non varchar column, perform the cast
338
334
  VectorOperations::Cast(context, input.data[col_idx], cast_chunk.data[col_idx], input.size());
@@ -1055,6 +1055,12 @@ void BufferedCSVReaderOptions::Serialize(FieldWriter &writer) const {
1055
1055
  writer.WriteSerializable(file_options);
1056
1056
  // write options
1057
1057
  writer.WriteListNoReference<bool>(force_quote);
1058
+ // FIXME: serialize date_format / has_format
1059
+ vector<string> csv_formats;
1060
+ for (auto &format : date_format) {
1061
+ csv_formats.push_back(format.second.format_specifier);
1062
+ }
1063
+ writer.WriteList<string>(csv_formats);
1058
1064
  }
1059
1065
 
1060
1066
  void BufferedCSVReaderOptions::Deserialize(FieldReader &reader) {
@@ -1091,6 +1097,17 @@ void BufferedCSVReaderOptions::Deserialize(FieldReader &reader) {
1091
1097
  file_options = reader.ReadRequiredSerializable<MultiFileReaderOptions, MultiFileReaderOptions>();
1092
1098
  // write options
1093
1099
  force_quote = reader.ReadRequiredList<bool>();
1100
+ auto formats = reader.ReadRequiredList<string>();
1101
+ vector<LogicalTypeId> format_types {LogicalTypeId::DATE, LogicalTypeId::TIMESTAMP};
1102
+ for (idx_t f_idx = 0; f_idx < formats.size(); f_idx++) {
1103
+ auto &format = formats[f_idx];
1104
+ auto &type = format_types[f_idx];
1105
+ if (format.empty()) {
1106
+ continue;
1107
+ }
1108
+ has_format[type] = true;
1109
+ StrTimeFormat::ParseFormatSpecifier(format, date_format[type]);
1110
+ }
1094
1111
  }
1095
1112
 
1096
1113
  static void CSVReaderSerialize(FieldWriter &writer, const FunctionData *bind_data_p, const TableFunction &function) {
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.7.2-dev3515"
2
+ #define DUCKDB_VERSION "0.7.2-dev3546"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "12638bd156"
5
+ #define DUCKDB_SOURCE_ID "bd8adef6d1"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -31,4 +31,14 @@ string TableMacroFunction::ToSQL(const string &schema, const string &name) const
31
31
  return MacroFunction::ToSQL(schema, name) + StringUtil::Format("TABLE (%s);", query_node->ToString());
32
32
  }
33
33
 
34
+ void TableMacroFunction::SerializeInternal(FieldWriter &writer) const {
35
+ writer.WriteSerializable(*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
+
34
44
  } // namespace duckdb
@@ -24,8 +24,10 @@ public:
24
24
  unique_ptr<MacroFunction> function;
25
25
 
26
26
  public:
27
+ virtual unique_ptr<CreateMacroInfo> GetInfoForSerialization() const;
27
28
  //! Serialize the meta information
28
- virtual void Serialize(Serializer &serializer) const = 0;
29
+ virtual void Serialize(Serializer &serializer) const;
30
+ static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &main_source, ClientContext &context);
29
31
 
30
32
  string ToSQL() const override {
31
33
  return function->ToSQL(schema.name, name);
@@ -23,11 +23,5 @@ public:
23
23
 
24
24
  public:
25
25
  ScalarMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info);
26
-
27
- public:
28
- //! Serialize the meta information of the ScalarMacroCatalogEntry
29
- void Serialize(Serializer &serializer) const override;
30
- //! Deserializes to a CreateMacroInfo
31
- static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &source, ClientContext &context);
32
26
  };
33
27
  } // namespace duckdb
@@ -22,12 +22,6 @@ public:
22
22
 
23
23
  public:
24
24
  TableMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info);
25
-
26
- public:
27
- //! Serialize the meta information of the ScalarMacroCatalogEntry
28
- void Serialize(Serializer &serializer) const override;
29
- //! Deserializes to a CreateMacroInfo
30
- static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &source, ClientContext &context);
31
25
  };
32
26
 
33
27
  } // namespace duckdb
@@ -15,6 +15,8 @@
15
15
  #include "duckdb/common/typedefs.hpp"
16
16
 
17
17
  namespace duckdb {
18
+ class Serializer;
19
+ class Deserializer;
18
20
 
19
21
  //! inline std directives that we use frequently
20
22
  #ifndef DUCKDB_DEBUG_MOVE
@@ -263,15 +263,15 @@ public:
263
263
  return ReadRequiredGenericList<T, idx_t, IndexReadOperation>();
264
264
  }
265
265
 
266
- template <class T>
267
- set<T> ReadRequiredSet() {
266
+ template <class T, class CONTAINER_TYPE = set<T>>
267
+ CONTAINER_TYPE ReadRequiredSet() {
268
268
  if (field_count >= max_field_count) {
269
269
  // field is not there, throw an exception
270
270
  throw SerializationException("Attempting to read a required field, but field is missing");
271
271
  }
272
272
  AddField();
273
273
  auto result_count = source.Read<uint32_t>();
274
- set<T> result;
274
+ CONTAINER_TYPE result;
275
275
  for (idx_t i = 0; i < result_count; i++) {
276
276
  result.insert(source.Read<T>());
277
277
  }
@@ -241,12 +241,22 @@ public:
241
241
 
242
242
  void PushBack(const Value &insert);
243
243
 
244
- idx_t capacity = 0;
245
- idx_t size = 0;
244
+ idx_t GetSize() {
245
+ return size;
246
+ }
247
+
248
+ idx_t GetCapacity() {
249
+ return capacity;
250
+ }
251
+
252
+ void SetCapacity(idx_t new_capacity);
253
+ void SetSize(idx_t new_size);
246
254
 
247
255
  private:
248
256
  //! child vectors used for nested data
249
257
  unique_ptr<Vector> child;
258
+ idx_t capacity = 0;
259
+ idx_t size = 0;
250
260
  };
251
261
 
252
262
  //! The ManagedVectorBuffer holds a buffer handle
@@ -130,8 +130,7 @@ struct BufferedCSVReaderOptions {
130
130
  std::map<LogicalTypeId, StrfTimeFormat> write_date_format = {{LogicalTypeId::DATE, {}},
131
131
  {LogicalTypeId::TIMESTAMP, {}}};
132
132
  //! Whether or not a type format is specified
133
- std::map<LogicalTypeId, bool> has_format = {
134
- {LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}, {LogicalTypeId::TIMESTAMP_TZ, false}};
133
+ std::map<LogicalTypeId, bool> has_format = {{LogicalTypeId::DATE, false}, {LogicalTypeId::TIMESTAMP, false}};
135
134
 
136
135
  void Serialize(FieldWriter &writer) const;
137
136
  void Deserialize(FieldReader &reader);
@@ -38,7 +38,7 @@ public:
38
38
  SinkResultType Sink(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const override;
39
39
 
40
40
  bool IsSink() const override {
41
- return info->query != nullptr;
41
+ return !children.empty();
42
42
  }
43
43
 
44
44
  bool ParallelSink() const override {
@@ -21,7 +21,7 @@ enum class MacroType : uint8_t { VOID_MACRO = 0, TABLE_MACRO = 1, SCALAR_MACRO =
21
21
 
22
22
  class MacroFunction {
23
23
  public:
24
- MacroFunction(MacroType type);
24
+ explicit MacroFunction(MacroType type);
25
25
 
26
26
  //! The type
27
27
  MacroType type;
@@ -45,6 +45,12 @@ public:
45
45
 
46
46
  virtual string ToSQL(const string &schema, const string &name) const;
47
47
 
48
+ void Serialize(Serializer &serializer) const;
49
+ static unique_ptr<MacroFunction> Deserialize(Deserializer &deserializer);
50
+
51
+ protected:
52
+ virtual void SerializeInternal(FieldWriter &writer) const = 0;
53
+
48
54
  public:
49
55
  template <class TARGET>
50
56
  TARGET &Cast() {
@@ -66,6 +66,9 @@ public:
66
66
  return std::find(specifiers.begin(), specifiers.end(), s) != specifiers.end();
67
67
  }
68
68
 
69
+ //! The full format specifier, for error messages
70
+ string format_specifier;
71
+
69
72
  protected:
70
73
  //! The format specifiers
71
74
  vector<StrTimeSpecifier> specifiers;
@@ -134,10 +137,6 @@ public:
134
137
  DUCKDB_API string FormatError(string_t input, const string &format_specifier);
135
138
  };
136
139
 
137
- public:
138
- //! The full format specifier, for error messages
139
- string format_specifier;
140
-
141
140
  public:
142
141
  DUCKDB_API static ParseResult Parse(const string &format, const string &text);
143
142
 
@@ -23,9 +23,9 @@ public:
23
23
  static constexpr const MacroType TYPE = MacroType::SCALAR_MACRO;
24
24
 
25
25
  public:
26
- ScalarMacroFunction(unique_ptr<ParsedExpression> expression);
27
-
26
+ explicit ScalarMacroFunction(unique_ptr<ParsedExpression> expression);
28
27
  ScalarMacroFunction(void);
28
+
29
29
  //! The macro expression
30
30
  unique_ptr<ParsedExpression> expression;
31
31
 
@@ -33,6 +33,11 @@ public:
33
33
  unique_ptr<MacroFunction> Copy() const override;
34
34
 
35
35
  string ToSQL(const string &schema, const string &name) const override;
36
+
37
+ static unique_ptr<MacroFunction> Deserialize(FieldReader &reader);
38
+
39
+ protected:
40
+ void SerializeInternal(FieldWriter &writer) const override;
36
41
  };
37
42
 
38
43
  } // namespace duckdb
@@ -33,6 +33,11 @@ public:
33
33
  unique_ptr<MacroFunction> Copy() const override;
34
34
 
35
35
  string ToSQL(const string &schema, const string &name) const override;
36
+
37
+ static unique_ptr<MacroFunction> Deserialize(FieldReader &reader);
38
+
39
+ protected:
40
+ void SerializeInternal(FieldWriter &writer) const override;
36
41
  };
37
42
 
38
43
  } // namespace duckdb
@@ -27,13 +27,10 @@ struct AttachInfo : public ParseInfo {
27
27
  unordered_map<string, Value> options;
28
28
 
29
29
  public:
30
- unique_ptr<AttachInfo> Copy() const {
31
- auto result = make_uniq<AttachInfo>();
32
- result->name = name;
33
- result->path = path;
34
- result->options = options;
35
- return result;
36
- }
30
+ unique_ptr<AttachInfo> Copy() const;
31
+
32
+ void Serialize(Serializer &serializer) const;
33
+ static unique_ptr<ParseInfo> Deserialize(Deserializer &deserializer);
37
34
  };
38
35
 
39
36
  } // namespace duckdb
@@ -14,22 +14,18 @@
14
14
  namespace duckdb {
15
15
 
16
16
  struct CreateMacroInfo : public CreateFunctionInfo {
17
- CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
18
- }
19
-
20
- CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
21
- }
17
+ CreateMacroInfo();
18
+ CreateMacroInfo(CatalogType type);
22
19
 
23
20
  unique_ptr<MacroFunction> function;
24
21
 
25
22
  public:
26
- unique_ptr<CreateInfo> Copy() const override {
27
- auto result = make_uniq<CreateMacroInfo>();
28
- result->function = function->Copy();
29
- result->name = name;
30
- CopyProperties(*result);
31
- return std::move(result);
32
- }
23
+ unique_ptr<CreateInfo> Copy() const override;
24
+
25
+ DUCKDB_API static unique_ptr<CreateMacroInfo> Deserialize(Deserializer &deserializer);
26
+
27
+ protected:
28
+ void SerializeInternal(Serializer &) const override;
33
29
  };
34
30
 
35
31
  } // namespace duckdb