duckdb 0.7.2-dev402.0 → 0.7.2-dev586.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 (105) hide show
  1. package/binding.gyp +9 -9
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +0 -1
  4. package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -0
  5. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +8 -6
  6. package/src/duckdb/src/catalog/catalog.cpp +13 -0
  7. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +2 -21
  8. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +8 -2
  9. package/src/duckdb/src/catalog/catalog_set.cpp +1 -0
  10. package/src/duckdb/src/common/arrow/arrow_appender.cpp +48 -4
  11. package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -1
  12. package/src/duckdb/src/common/field_writer.cpp +1 -0
  13. package/src/duckdb/src/common/serializer/buffered_deserializer.cpp +4 -0
  14. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +15 -2
  15. package/src/duckdb/src/common/types.cpp +136 -53
  16. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -40
  17. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +9 -1
  18. package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +5 -8
  19. package/src/duckdb/src/function/aggregate/distributive/bool.cpp +2 -0
  20. package/src/duckdb/src/function/aggregate/distributive/count.cpp +1 -0
  21. package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +2 -0
  22. package/src/duckdb/src/function/aggregate/distributive/sum.cpp +8 -0
  23. package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +15 -0
  24. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +42 -11
  25. package/src/duckdb/src/function/function_binder.cpp +1 -8
  26. package/src/duckdb/src/function/scalar/date/current.cpp +0 -2
  27. package/src/duckdb/src/function/table/arrow.cpp +3 -0
  28. package/src/duckdb/src/function/table/arrow_conversion.cpp +18 -0
  29. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  30. package/src/duckdb/src/function/table_function.cpp +11 -11
  31. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -0
  32. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -1
  33. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +12 -4
  34. package/src/duckdb/src/include/duckdb/common/{http_stats.hpp → http_state.hpp} +18 -4
  35. package/src/duckdb/src/include/duckdb/common/serializer/buffered_deserializer.hpp +4 -2
  36. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +8 -2
  37. package/src/duckdb/src/include/duckdb/common/serializer.hpp +13 -0
  38. package/src/duckdb/src/include/duckdb/common/types.hpp +27 -1
  39. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +1 -0
  40. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +0 -3
  41. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +6 -3
  42. package/src/duckdb/src/include/duckdb/function/function_binder.hpp +3 -6
  43. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +12 -1
  44. package/src/duckdb/src/include/duckdb/function/table_function.hpp +8 -0
  45. package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -3
  46. package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -0
  47. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
  48. package/src/duckdb/src/include/duckdb/optimizer/rule/list.hpp +1 -0
  49. package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +24 -0
  50. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +2 -2
  51. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +2 -2
  52. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +3 -0
  53. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +6 -0
  54. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
  55. package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -3
  56. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +3 -0
  57. package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +3 -0
  58. package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +4 -1
  59. package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +3 -0
  60. package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +1 -1
  61. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +7 -0
  62. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +1 -1
  63. package/src/duckdb/src/main/client_context.cpp +30 -32
  64. package/src/duckdb/src/main/client_data.cpp +7 -6
  65. package/src/duckdb/src/main/database.cpp +9 -0
  66. package/src/duckdb/src/main/query_profiler.cpp +17 -15
  67. package/src/duckdb/src/optimizer/optimizer.cpp +1 -0
  68. package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +30 -0
  69. package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +9 -2
  70. package/src/duckdb/src/parser/expression/star_expression.cpp +6 -6
  71. package/src/duckdb/src/parser/parsed_expression_iterator.cpp +7 -1
  72. package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +17 -2
  73. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +45 -40
  74. package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +7 -0
  75. package/src/duckdb/src/parser/transform/helpers/transform_orderby.cpp +0 -7
  76. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +3 -4
  77. package/src/duckdb/src/planner/bind_context.cpp +2 -25
  78. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +6 -4
  79. package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +3 -2
  80. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +176 -0
  81. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +57 -82
  82. package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +11 -0
  83. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  84. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
  85. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  86. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +11 -1
  87. package/src/duckdb/src/planner/binder.cpp +12 -23
  88. package/src/duckdb/src/planner/bound_result_modifier.cpp +26 -0
  89. package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +9 -2
  90. package/src/duckdb/src/planner/expression_iterator.cpp +5 -0
  91. package/src/duckdb/src/planner/logical_operator.cpp +4 -2
  92. package/src/duckdb/src/planner/logical_operator_visitor.cpp +5 -0
  93. package/src/duckdb/src/planner/operator/logical_distinct.cpp +3 -0
  94. package/src/duckdb/src/planner/planner.cpp +2 -1
  95. package/src/duckdb/src/storage/checkpoint_manager.cpp +8 -3
  96. package/src/duckdb/src/storage/meta_block_reader.cpp +22 -0
  97. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  98. package/src/duckdb/src/storage/wal_replay.cpp +8 -5
  99. package/src/duckdb/src/storage/write_ahead_log.cpp +2 -2
  100. package/src/duckdb/src/transaction/commit_state.cpp +11 -7
  101. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -1
  102. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +8145 -8317
  103. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
  104. package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
  105. package/src/duckdb/ub_src_planner_binder_expression.cpp +2 -0
package/binding.gyp CHANGED
@@ -223,18 +223,18 @@
223
223
  "src/duckdb/third_party/zstd/compress/zstd_lazy.cpp",
224
224
  "src/duckdb/third_party/zstd/compress/zstd_ldm.cpp",
225
225
  "src/duckdb/third_party/zstd/compress/zstd_opt.cpp",
226
- "src/duckdb/extension/icu/./icu-dateadd.cpp",
227
- "src/duckdb/extension/icu/./icu-table-range.cpp",
228
- "src/duckdb/extension/icu/./icu-datetrunc.cpp",
229
- "src/duckdb/extension/icu/./icu-strptime.cpp",
230
- "src/duckdb/extension/icu/./icu-datefunc.cpp",
231
- "src/duckdb/extension/icu/./icu-extension.cpp",
232
- "src/duckdb/extension/icu/./icu-makedate.cpp",
233
226
  "src/duckdb/extension/icu/./icu-list-range.cpp",
227
+ "src/duckdb/extension/icu/./icu-datepart.cpp",
228
+ "src/duckdb/extension/icu/./icu-timebucket.cpp",
234
229
  "src/duckdb/extension/icu/./icu-timezone.cpp",
230
+ "src/duckdb/extension/icu/./icu-datefunc.cpp",
231
+ "src/duckdb/extension/icu/./icu-makedate.cpp",
232
+ "src/duckdb/extension/icu/./icu-datetrunc.cpp",
233
+ "src/duckdb/extension/icu/./icu-table-range.cpp",
234
+ "src/duckdb/extension/icu/./icu-extension.cpp",
235
+ "src/duckdb/extension/icu/./icu-dateadd.cpp",
235
236
  "src/duckdb/extension/icu/./icu-datesub.cpp",
236
- "src/duckdb/extension/icu/./icu-timebucket.cpp",
237
- "src/duckdb/extension/icu/./icu-datepart.cpp",
237
+ "src/duckdb/extension/icu/./icu-strptime.cpp",
238
238
  "src/duckdb/ub_extension_icu_third_party_icu_common.cpp",
239
239
  "src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp",
240
240
  "src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp",
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-dev402.0",
5
+ "version": "0.7.2-dev586.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -16,7 +16,6 @@ struct Int96 {
16
16
  uint32_t value[3];
17
17
  };
18
18
 
19
- int64_t ImpalaTimestampToNanoseconds(const Int96 &impala_timestamp);
20
19
  timestamp_t ImpalaTimestampToTimestamp(const Int96 &raw_ts);
21
20
  Int96 TimestampToImpalaTimestamp(timestamp_t &ts);
22
21
  timestamp_t ParquetTimestampMicrosToTimestamp(const int64_t &raw_ts);
@@ -354,6 +354,7 @@ public:
354
354
  return_types.assign(union_col_types.begin(), union_col_types.end());
355
355
  result->SetInitialReader(result->union_readers[0]);
356
356
  D_ASSERT(names.size() == return_types.size());
357
+ result->types = union_col_types;
357
358
 
358
359
  return std::move(result);
359
360
  }
@@ -12,24 +12,26 @@ namespace duckdb {
12
12
  // surely they are joking
13
13
  static constexpr int64_t JULIAN_TO_UNIX_EPOCH_DAYS = 2440588LL;
14
14
  static constexpr int64_t MILLISECONDS_PER_DAY = 86400000LL;
15
- static constexpr int64_t NANOSECONDS_PER_DAY = MILLISECONDS_PER_DAY * 1000LL * 1000LL;
15
+ static constexpr int64_t MICROSECONDS_PER_DAY = MILLISECONDS_PER_DAY * 1000LL;
16
+ static constexpr int64_t NANOSECONDS_PER_MICRO = 1000LL;
16
17
 
17
- int64_t ImpalaTimestampToNanoseconds(const Int96 &impala_timestamp) {
18
+ static int64_t ImpalaTimestampToMicroseconds(const Int96 &impala_timestamp) {
18
19
  int64_t days_since_epoch = impala_timestamp.value[2] - JULIAN_TO_UNIX_EPOCH_DAYS;
19
20
  auto nanoseconds = Load<int64_t>((data_ptr_t)impala_timestamp.value);
20
- return days_since_epoch * NANOSECONDS_PER_DAY + nanoseconds;
21
+ auto microseconds = nanoseconds / NANOSECONDS_PER_MICRO;
22
+ return days_since_epoch * MICROSECONDS_PER_DAY + microseconds;
21
23
  }
22
24
 
23
25
  timestamp_t ImpalaTimestampToTimestamp(const Int96 &raw_ts) {
24
- auto impala_ns = ImpalaTimestampToNanoseconds(raw_ts);
25
- return Timestamp::FromEpochNanoSeconds(impala_ns);
26
+ auto impala_us = ImpalaTimestampToMicroseconds(raw_ts);
27
+ return Timestamp::FromEpochMicroSeconds(impala_us);
26
28
  }
27
29
 
28
30
  Int96 TimestampToImpalaTimestamp(timestamp_t &ts) {
29
31
  int32_t hour, min, sec, msec;
30
32
  Time::Convert(Timestamp::GetTime(ts), hour, min, sec, msec);
31
33
  uint64_t ms_since_midnight = hour * 60 * 60 * 1000 + min * 60 * 1000 + sec * 1000 + msec;
32
- auto days_since_epoch = Date::Epoch(Timestamp::GetDate(ts)) / (24 * 60 * 60);
34
+ auto days_since_epoch = Date::Epoch(Timestamp::GetDate(ts)) / int64_t(24 * 60 * 60);
33
35
  // first two uint32 in Int96 are nanoseconds since midnights
34
36
  // last uint32 is number of days since year 4713 BC ("Julian date")
35
37
  Int96 impala_ts;
@@ -625,6 +625,19 @@ vector<SchemaCatalogEntry *> Catalog::GetSchemas(ClientContext &context) {
625
625
  return schemas;
626
626
  }
627
627
 
628
+ bool Catalog::TypeExists(ClientContext &context, const string &catalog_name, const string &schema, const string &name) {
629
+ CatalogEntry *entry;
630
+ entry = GetEntry(context, CatalogType::TYPE_ENTRY, catalog_name, schema, name, true);
631
+ if (!entry) {
632
+ // look in the system catalog
633
+ entry = GetEntry(context, CatalogType::TYPE_ENTRY, SYSTEM_CATALOG, schema, name, true);
634
+ if (!entry) {
635
+ return false;
636
+ }
637
+ }
638
+ return true;
639
+ }
640
+
628
641
  vector<SchemaCatalogEntry *> Catalog::GetSchemas(ClientContext &context, const string &catalog_name) {
629
642
  vector<Catalog *> catalogs;
630
643
  if (IsInvalidCatalog(catalog_name)) {
@@ -682,27 +682,8 @@ void DuckTableEntry::SetAsRoot() {
682
682
  storage->info->table = name;
683
683
  }
684
684
 
685
- void DuckTableEntry::CommitAlter(AlterInfo &info) {
686
- D_ASSERT(info.type == AlterType::ALTER_TABLE);
687
- auto &alter_table = (AlterTableInfo &)info;
688
- string column_name;
689
- switch (alter_table.alter_table_type) {
690
- case AlterTableType::REMOVE_COLUMN: {
691
- auto &remove_info = (RemoveColumnInfo &)alter_table;
692
- column_name = remove_info.removed_column;
693
- break;
694
- }
695
- case AlterTableType::ALTER_COLUMN_TYPE: {
696
- auto &change_info = (ChangeColumnTypeInfo &)alter_table;
697
- column_name = change_info.column_name;
698
- break;
699
- }
700
- default:
701
- break;
702
- }
703
- if (column_name.empty()) {
704
- return;
705
- }
685
+ void DuckTableEntry::CommitAlter(string &column_name) {
686
+ D_ASSERT(!column_name.empty());
706
687
  idx_t removed_index = DConstants::INVALID_INDEX;
707
688
  for (auto &col : columns.Logical()) {
708
689
  if (col.Name() == column_name) {
@@ -23,7 +23,13 @@ void TypeCatalogEntry::Serialize(Serializer &serializer) {
23
23
  FieldWriter writer(serializer);
24
24
  writer.WriteString(schema->name);
25
25
  writer.WriteString(name);
26
- writer.WriteSerializable(user_type);
26
+ if (user_type.id() == LogicalTypeId::ENUM) {
27
+ // We have to serialize Enum Values
28
+ writer.AddField();
29
+ user_type.SerializeEnumType(writer.GetSerializer());
30
+ } else {
31
+ writer.WriteSerializable(user_type);
32
+ }
27
33
  writer.Finalize();
28
34
  }
29
35
 
@@ -43,7 +49,7 @@ string TypeCatalogEntry::ToSQL() {
43
49
  std::stringstream ss;
44
50
  switch (user_type.id()) {
45
51
  case (LogicalTypeId::ENUM): {
46
- Vector values_insert_order(EnumType::GetValuesInsertOrder(user_type));
52
+ auto &values_insert_order = EnumType::GetValuesInsertOrder(user_type);
47
53
  idx_t size = EnumType::GetSize(user_type);
48
54
  ss << "CREATE TYPE ";
49
55
  ss << KeywordHelper::WriteOptionallyQuoted(name);
@@ -258,6 +258,7 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
258
258
 
259
259
  // serialize the AlterInfo into a temporary buffer
260
260
  BufferedSerializer serializer;
261
+ serializer.WriteString(alter_info->GetColumnName());
261
262
  alter_info->Serialize(serializer);
262
263
  BinaryData serialized_alter = serializer.GetData();
263
264
 
@@ -4,6 +4,7 @@
4
4
  #include "duckdb/common/array.hpp"
5
5
  #include "duckdb/common/types/interval.hpp"
6
6
  #include "duckdb/common/types/uuid.hpp"
7
+ #include "duckdb/function/table/arrow.hpp"
7
8
 
8
9
  namespace duckdb {
9
10
 
@@ -127,7 +128,11 @@ struct ArrowScalarConverter {
127
128
  struct ArrowIntervalConverter {
128
129
  template <class TGT, class SRC>
129
130
  static TGT Operation(SRC input) {
130
- return Interval::GetMilli(input);
131
+ ArrowInterval result;
132
+ result.months = input.months;
133
+ result.days = input.days;
134
+ result.nanoseconds = input.micros * Interval::NANOS_PER_MICRO;
135
+ return result;
131
136
  }
132
137
 
133
138
  static bool SkipNulls() {
@@ -136,7 +141,6 @@ struct ArrowIntervalConverter {
136
141
 
137
142
  template <class TGT>
138
143
  static void SetNull(TGT &value) {
139
- value = 0;
140
144
  }
141
145
  };
142
146
 
@@ -185,11 +189,51 @@ struct ArrowScalarData : public ArrowScalarBaseData<TGT, SRC, OP> {
185
189
  //===--------------------------------------------------------------------===//
186
190
  template <class TGT>
187
191
  struct ArrowEnumData : public ArrowScalarBaseData<TGT> {
192
+ static idx_t GetLength(string_t input) {
193
+ return input.GetSize();
194
+ }
195
+ static void WriteData(data_ptr_t target, string_t input) {
196
+ memcpy(target, input.GetDataUnsafe(), input.GetSize());
197
+ }
198
+ static void EnumAppendVector(ArrowAppendData &append_data, const Vector &input, idx_t size) {
199
+ D_ASSERT(input.GetVectorType() == VectorType::FLAT_VECTOR);
200
+
201
+ // resize the validity mask and set up the validity buffer for iteration
202
+ ResizeValidity(append_data.validity, append_data.row_count + size);
203
+
204
+ // resize the offset buffer - the offset buffer holds the offsets into the child array
205
+ append_data.main_buffer.resize(append_data.main_buffer.size() + sizeof(uint32_t) * (size + 1));
206
+ auto data = (string_t *)FlatVector::GetData<string_t>(input);
207
+ auto offset_data = (uint32_t *)append_data.main_buffer.data();
208
+ if (append_data.row_count == 0) {
209
+ // first entry
210
+ offset_data[0] = 0;
211
+ }
212
+ // now append the string data to the auxiliary buffer
213
+ // the auxiliary buffer's length depends on the string lengths, so we resize as required
214
+ auto last_offset = offset_data[append_data.row_count];
215
+ for (idx_t i = 0; i < size; i++) {
216
+ auto offset_idx = append_data.row_count + i + 1;
217
+
218
+ auto string_length = GetLength(data[i]);
219
+
220
+ // append the offset data
221
+ auto current_offset = last_offset + string_length;
222
+ offset_data[offset_idx] = current_offset;
223
+
224
+ // resize the string buffer if required, and write the string data
225
+ append_data.aux_buffer.resize(current_offset);
226
+ WriteData(append_data.aux_buffer.data() + last_offset, data[i]);
227
+
228
+ last_offset = current_offset;
229
+ }
230
+ append_data.row_count += size;
231
+ }
188
232
  static void Initialize(ArrowAppendData &result, const LogicalType &type, idx_t capacity) {
189
233
  result.main_buffer.reserve(capacity * sizeof(TGT));
190
234
  // construct the enum child data
191
235
  auto enum_data = InitializeArrowChild(LogicalType::VARCHAR, EnumType::GetSize(type));
192
- enum_data->append_vector(*enum_data, EnumType::GetValuesInsertOrder(type), EnumType::GetSize(type));
236
+ EnumAppendVector(*enum_data, EnumType::GetValuesInsertOrder(type), EnumType::GetSize(type));
193
237
  result.child_data.push_back(std::move(enum_data));
194
238
  }
195
239
 
@@ -629,7 +673,7 @@ static void InitializeFunctionPointers(ArrowAppendData &append_data, const Logic
629
673
  }
630
674
  break;
631
675
  case LogicalTypeId::INTERVAL:
632
- InitializeFunctionPointers<ArrowScalarData<int64_t, interval_t, ArrowIntervalConverter>>(append_data);
676
+ InitializeFunctionPointers<ArrowScalarData<ArrowInterval, interval_t, ArrowIntervalConverter>>(append_data);
633
677
  break;
634
678
  case LogicalTypeId::STRUCT:
635
679
  InitializeFunctionPointers<ArrowStructData>(append_data);
@@ -150,7 +150,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
150
150
  child.format = "tsm:";
151
151
  break;
152
152
  case LogicalTypeId::INTERVAL:
153
- child.format = "tDm";
153
+ child.format = "tin";
154
154
  break;
155
155
  case LogicalTypeId::DECIMAL: {
156
156
  uint8_t width, scale;
@@ -8,6 +8,7 @@ namespace duckdb {
8
8
  FieldWriter::FieldWriter(Serializer &serializer_p)
9
9
  : serializer(serializer_p), buffer(make_unique<BufferedSerializer>()), field_count(0), finalized(false) {
10
10
  buffer->SetVersion(serializer.GetVersion());
11
+ buffer->is_query_plan = serializer.is_query_plan;
11
12
  }
12
13
 
13
14
  FieldWriter::~FieldWriter() {
@@ -20,4 +20,8 @@ void BufferedDeserializer::ReadData(data_ptr_t buffer, idx_t read_size) {
20
20
  ptr += read_size;
21
21
  }
22
22
 
23
+ ClientContext &BufferedContextDeserializer::GetContext() {
24
+ return context;
25
+ }
26
+
23
27
  } // namespace duckdb
@@ -7,8 +7,10 @@
7
7
 
8
8
  namespace duckdb {
9
9
 
10
- BufferedFileReader::BufferedFileReader(FileSystem &fs, const char *path, FileLockType lock_type, FileOpener *opener)
11
- : fs(fs), data(unique_ptr<data_t[]>(new data_t[FILE_BUFFER_SIZE])), offset(0), read_data(0), total_read(0) {
10
+ BufferedFileReader::BufferedFileReader(FileSystem &fs, const char *path, ClientContext *context, FileLockType lock_type,
11
+ FileOpener *opener)
12
+ : fs(fs), data(unique_ptr<data_t[]>(new data_t[FILE_BUFFER_SIZE])), offset(0), read_data(0), context(context),
13
+ total_read(0) {
12
14
  handle = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ, lock_type, FileSystem::DEFAULT_COMPRESSION, opener);
13
15
  file_size = fs.GetFileSize(*handle);
14
16
  }
@@ -54,4 +56,15 @@ uint64_t BufferedFileReader::CurrentOffset() {
54
56
  return total_read + offset;
55
57
  }
56
58
 
59
+ ClientContext &BufferedFileReader::GetContext() {
60
+ if (!context) {
61
+ throw InternalException("Trying to acquire a client context that does not exist");
62
+ }
63
+ return *context;
64
+ }
65
+
66
+ Catalog *BufferedFileReader::GetCatalog() {
67
+ return catalog;
68
+ }
69
+
57
70
  } // namespace duckdb