duckdb 0.7.2-dev457.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 (54) hide show
  1. package/binding.gyp +9 -9
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -0
  4. package/src/duckdb/src/catalog/catalog.cpp +13 -0
  5. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +2 -21
  6. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +8 -2
  7. package/src/duckdb/src/catalog/catalog_set.cpp +1 -0
  8. package/src/duckdb/src/common/arrow/arrow_appender.cpp +48 -4
  9. package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -1
  10. package/src/duckdb/src/common/field_writer.cpp +1 -0
  11. package/src/duckdb/src/common/serializer/buffered_deserializer.cpp +4 -0
  12. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +15 -2
  13. package/src/duckdb/src/common/types.cpp +136 -53
  14. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -40
  15. package/src/duckdb/src/function/table/arrow.cpp +3 -0
  16. package/src/duckdb/src/function/table/arrow_conversion.cpp +18 -0
  17. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  18. package/src/duckdb/src/function/table_function.cpp +11 -11
  19. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -0
  20. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -1
  21. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +12 -4
  22. package/src/duckdb/src/include/duckdb/common/{http_stats.hpp → http_state.hpp} +18 -4
  23. package/src/duckdb/src/include/duckdb/common/serializer/buffered_deserializer.hpp +4 -2
  24. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +8 -2
  25. package/src/duckdb/src/include/duckdb/common/serializer.hpp +13 -0
  26. package/src/duckdb/src/include/duckdb/common/types.hpp +27 -1
  27. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +1 -0
  28. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +12 -1
  29. package/src/duckdb/src/include/duckdb/function/table_function.hpp +8 -0
  30. package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -3
  31. package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -0
  32. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
  33. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +3 -0
  34. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +6 -0
  35. package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +1 -1
  36. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +7 -0
  37. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +1 -1
  38. package/src/duckdb/src/main/client_context.cpp +30 -32
  39. package/src/duckdb/src/main/client_data.cpp +7 -6
  40. package/src/duckdb/src/main/database.cpp +9 -0
  41. package/src/duckdb/src/main/query_profiler.cpp +17 -15
  42. package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +9 -2
  43. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +3 -4
  44. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +11 -1
  45. package/src/duckdb/src/planner/logical_operator.cpp +4 -2
  46. package/src/duckdb/src/planner/planner.cpp +2 -1
  47. package/src/duckdb/src/storage/checkpoint_manager.cpp +8 -3
  48. package/src/duckdb/src/storage/meta_block_reader.cpp +22 -0
  49. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  50. package/src/duckdb/src/storage/wal_replay.cpp +8 -5
  51. package/src/duckdb/src/storage/write_ahead_log.cpp +2 -2
  52. package/src/duckdb/src/transaction/commit_state.cpp +11 -7
  53. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +1152 -1152
  54. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
@@ -15,10 +15,11 @@ PhysicalCreateType::PhysicalCreateType(unique_ptr<CreateTypeInfo> info, idx_t es
15
15
  //===--------------------------------------------------------------------===//
16
16
  class CreateTypeGlobalState : public GlobalSinkState {
17
17
  public:
18
- explicit CreateTypeGlobalState(ClientContext &context) : collection(context, {LogicalType::VARCHAR}) {
18
+ explicit CreateTypeGlobalState(ClientContext &context) : result(LogicalType::VARCHAR) {
19
19
  }
20
-
21
- ColumnDataCollection collection;
20
+ Vector result;
21
+ idx_t size = 0;
22
+ idx_t capacity = STANDARD_VECTOR_SIZE;
22
23
  };
23
24
 
24
25
  unique_ptr<GlobalSinkState> PhysicalCreateType::GetGlobalSinkState(ClientContext &context) const {
@@ -28,7 +29,7 @@ unique_ptr<GlobalSinkState> PhysicalCreateType::GetGlobalSinkState(ClientContext
28
29
  SinkResultType PhysicalCreateType::Sink(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p,
29
30
  DataChunk &input) const {
30
31
  auto &gstate = (CreateTypeGlobalState &)gstate_p;
31
- idx_t total_row_count = gstate.collection.Count() + input.size();
32
+ idx_t total_row_count = gstate.size + input.size();
32
33
  if (total_row_count > NumericLimits<uint32_t>::Maximum()) {
33
34
  throw InvalidInputException("Attempted to create ENUM of size %llu, which exceeds the maximum size of %llu",
34
35
  total_row_count, NumericLimits<uint32_t>::Maximum());
@@ -36,15 +37,23 @@ SinkResultType PhysicalCreateType::Sink(ExecutionContext &context, GlobalSinkSta
36
37
  UnifiedVectorFormat sdata;
37
38
  input.data[0].ToUnifiedFormat(input.size(), sdata);
38
39
 
40
+ if (total_row_count > gstate.capacity) {
41
+ // We must resize our result vector
42
+ gstate.result.Resize(gstate.capacity, gstate.capacity * 2);
43
+ gstate.capacity *= 2;
44
+ }
45
+
46
+ auto src_ptr = (string_t *)sdata.data;
47
+ auto result_ptr = FlatVector::GetData<string_t>(gstate.result);
39
48
  // Input vector has NULL value, we just throw an exception
40
49
  for (idx_t i = 0; i < input.size(); i++) {
41
50
  idx_t idx = sdata.sel->get_index(i);
42
51
  if (!sdata.validity.RowIsValid(idx)) {
43
52
  throw InvalidInputException("Attempted to create ENUM type with NULL value!");
44
53
  }
54
+ result_ptr[gstate.size++] =
55
+ StringVector::AddStringOrBlob(gstate.result, src_ptr[idx].GetDataUnsafe(), src_ptr[idx].GetSize());
45
56
  }
46
-
47
- gstate.collection.Append(input);
48
57
  return SinkResultType::NEED_MORE_INPUT;
49
58
  }
50
59
 
@@ -72,44 +81,15 @@ void PhysicalCreateType::GetData(ExecutionContext &context, DataChunk &chunk, Gl
72
81
 
73
82
  if (IsSink()) {
74
83
  D_ASSERT(info->type == LogicalType::INVALID);
75
-
76
84
  auto &g_sink_state = (CreateTypeGlobalState &)*sink_state;
77
- auto &collection = g_sink_state.collection;
78
-
79
- idx_t total_row_count = collection.Count();
80
-
81
- ColumnDataScanState scan_state;
82
- collection.InitializeScan(scan_state);
83
-
84
- DataChunk scan_chunk;
85
- collection.InitializeScanChunk(scan_chunk);
86
-
87
- Vector result(LogicalType::VARCHAR, total_row_count);
88
- auto result_ptr = FlatVector::GetData<string_t>(result);
89
-
90
- idx_t offset = 0;
91
- while (collection.Scan(scan_state, scan_chunk)) {
92
- idx_t src_row_count = scan_chunk.size();
93
- auto &src_vec = scan_chunk.data[0];
94
- D_ASSERT(src_vec.GetVectorType() == VectorType::FLAT_VECTOR);
95
- D_ASSERT(src_vec.GetType().id() == LogicalType::VARCHAR);
96
-
97
- auto src_ptr = FlatVector::GetData<string_t>(src_vec);
98
-
99
- for (idx_t i = 0; i < src_row_count; i++) {
100
- idx_t target_index = offset + i;
101
- result_ptr[target_index] =
102
- StringVector::AddStringOrBlob(result, src_ptr[i].GetDataUnsafe(), src_ptr[i].GetSize());
103
- }
104
-
105
- offset += src_row_count;
106
- }
107
-
108
- info->type = LogicalType::ENUM(info->name, result, total_row_count);
85
+ info->type = LogicalType::ENUM(info->name, g_sink_state.result, g_sink_state.size);
109
86
  }
110
87
 
111
88
  auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
112
- catalog.CreateType(context.client, info.get());
89
+ auto catalog_entry = catalog.CreateType(context.client, info.get());
90
+ D_ASSERT(catalog_entry->type == CatalogType::TYPE_ENTRY);
91
+ auto catalog_type = (TypeCatalogEntry *)catalog_entry;
92
+ LogicalType::SetCatalog(info->type, catalog_type);
113
93
  state.finished = true;
114
94
  }
115
95
 
@@ -101,6 +101,9 @@ LogicalType ArrowTableFunction::GetArrowLogicalType(
101
101
  } else if (format == "tiM") {
102
102
  arrow_convert_data[col_idx]->date_time_precision.emplace_back(ArrowDateTimeType::MONTHS);
103
103
  return LogicalType::INTERVAL;
104
+ } else if (format == "tin") {
105
+ arrow_convert_data[col_idx]->date_time_precision.emplace_back(ArrowDateTimeType::MONTH_DAY_NANO);
106
+ return LogicalType::INTERVAL;
104
107
  } else if (format == "+l") {
105
108
  arrow_convert_data[col_idx]->variable_sz_type.emplace_back(ArrowVariableSizeType::NORMAL, 0);
106
109
  auto child_type = GetArrowLogicalType(*schema.children[0], arrow_convert_data, col_idx);
@@ -316,6 +316,20 @@ void IntervalConversionMonths(Vector &vector, ArrowArray &array, ArrowScanLocalS
316
316
  }
317
317
  }
318
318
 
319
+ void IntervalConversionMonthDayNanos(Vector &vector, ArrowArray &array, ArrowScanLocalState &scan_state,
320
+ int64_t nested_offset, idx_t size) {
321
+ auto tgt_ptr = (interval_t *)FlatVector::GetData(vector);
322
+ auto src_ptr = (ArrowInterval *)array.buffers[1] + scan_state.chunk_offset + array.offset;
323
+ if (nested_offset != -1) {
324
+ src_ptr = (ArrowInterval *)array.buffers[1] + nested_offset + array.offset;
325
+ }
326
+ for (idx_t row = 0; row < size; row++) {
327
+ tgt_ptr[row].days = src_ptr[row].days;
328
+ tgt_ptr[row].micros = src_ptr[row].nanoseconds / Interval::NANOS_PER_MICRO;
329
+ tgt_ptr[row].months = src_ptr[row].months;
330
+ }
331
+ }
332
+
319
333
  void ColumnArrowToDuckDB(Vector &vector, ArrowArray &array, ArrowScanLocalState &scan_state, idx_t size,
320
334
  std::unordered_map<idx_t, unique_ptr<ArrowConvertData>> &arrow_convert_data, idx_t col_idx,
321
335
  std::pair<idx_t, idx_t> &arrow_convert_idx, int64_t nested_offset, ValidityMask *parent_mask) {
@@ -509,6 +523,10 @@ void ColumnArrowToDuckDB(Vector &vector, ArrowArray &array, ArrowScanLocalState
509
523
  IntervalConversionMonths(vector, array, scan_state, nested_offset, size);
510
524
  break;
511
525
  }
526
+ case ArrowDateTimeType::MONTH_DAY_NANO: {
527
+ IntervalConversionMonthDayNanos(vector, array, scan_state, nested_offset, size);
528
+ break;
529
+ }
512
530
  default:
513
531
  throw std::runtime_error("Unsupported precision for Interval/Duration Type ");
514
532
  }
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.7.2-dev457"
2
+ #define DUCKDB_VERSION "0.7.2-dev586"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "403d0ca315"
5
+ #define DUCKDB_SOURCE_ID "23ee8b036a"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -14,12 +14,12 @@ TableFunctionInfo::~TableFunctionInfo() {
14
14
  TableFunction::TableFunction(string name, vector<LogicalType> arguments, table_function_t function,
15
15
  table_function_bind_t bind, table_function_init_global_t init_global,
16
16
  table_function_init_local_t init_local)
17
- : SimpleNamedParameterFunction(std::move(name), std::move(arguments)), bind(bind), init_global(init_global),
18
- init_local(init_local), function(function), in_out_function(nullptr), in_out_function_final(nullptr),
19
- statistics(nullptr), dependency(nullptr), cardinality(nullptr), pushdown_complex_filter(nullptr),
20
- to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr), get_batch_info(nullptr),
21
- serialize(nullptr), deserialize(nullptr), projection_pushdown(false), filter_pushdown(false),
22
- filter_prune(false) {
17
+ : SimpleNamedParameterFunction(std::move(name), std::move(arguments)), bind(bind), bind_replace(nullptr),
18
+ init_global(init_global), init_local(init_local), function(function), in_out_function(nullptr),
19
+ in_out_function_final(nullptr), statistics(nullptr), dependency(nullptr), cardinality(nullptr),
20
+ pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr),
21
+ get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr), projection_pushdown(false),
22
+ filter_pushdown(false), filter_prune(false) {
23
23
  }
24
24
 
25
25
  TableFunction::TableFunction(const vector<LogicalType> &arguments, table_function_t function,
@@ -28,11 +28,11 @@ TableFunction::TableFunction(const vector<LogicalType> &arguments, table_functio
28
28
  : TableFunction(string(), arguments, function, bind, init_global, init_local) {
29
29
  }
30
30
  TableFunction::TableFunction()
31
- : SimpleNamedParameterFunction("", {}), bind(nullptr), init_global(nullptr), init_local(nullptr), function(nullptr),
32
- in_out_function(nullptr), statistics(nullptr), dependency(nullptr), cardinality(nullptr),
33
- pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr),
34
- get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr), projection_pushdown(false),
35
- filter_pushdown(false), filter_prune(false) {
31
+ : SimpleNamedParameterFunction("", {}), bind(nullptr), bind_replace(nullptr), init_global(nullptr),
32
+ init_local(nullptr), function(nullptr), in_out_function(nullptr), statistics(nullptr), dependency(nullptr),
33
+ cardinality(nullptr), pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr),
34
+ get_batch_index(nullptr), get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr),
35
+ projection_pushdown(false), filter_pushdown(false), filter_prune(false) {
36
36
  }
37
37
 
38
38
  bool TableFunction::Equal(const TableFunction &rhs) const {
@@ -205,6 +205,9 @@ public:
205
205
  DUCKDB_API static LogicalType GetType(ClientContext &context, const string &catalog_name, const string &schema,
206
206
  const string &name);
207
207
 
208
+ static bool TypeExists(ClientContext &context, const string &catalog_name, const string &schema,
209
+ const string &name);
210
+
208
211
  template <class T>
209
212
  T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
210
213
  QueryErrorContext error_context = QueryErrorContext()) {
@@ -35,7 +35,7 @@ public:
35
35
 
36
36
  void SetAsRoot() override;
37
37
 
38
- void CommitAlter(AlterInfo &info);
38
+ void CommitAlter(string &column_name);
39
39
  void CommitDrop();
40
40
 
41
41
  TableFunction GetScanFunction(ClientContext &context, unique_ptr<FunctionData> &bind_data) override;
@@ -25,7 +25,7 @@ struct IndexWriteOperation {
25
25
 
26
26
  class FieldWriter {
27
27
  public:
28
- DUCKDB_API FieldWriter(Serializer &serializer);
28
+ DUCKDB_API explicit FieldWriter(Serializer &serializer);
29
29
  DUCKDB_API ~FieldWriter();
30
30
 
31
31
  public:
@@ -128,11 +128,11 @@ public:
128
128
  return *buffer;
129
129
  }
130
130
 
131
- private:
132
131
  void AddField() {
133
132
  field_count++;
134
133
  }
135
134
 
135
+ private:
136
136
  template <class T>
137
137
  void Write(const T &element) {
138
138
  WriteData((const_data_ptr_t)&element, sizeof(T));
@@ -152,7 +152,7 @@ DUCKDB_API void FieldWriter::Write(const string &val);
152
152
 
153
153
  class FieldDeserializer : public Deserializer {
154
154
  public:
155
- FieldDeserializer(Deserializer &root);
155
+ explicit FieldDeserializer(Deserializer &root);
156
156
 
157
157
  public:
158
158
  void ReadData(data_ptr_t buffer, idx_t read_size) override;
@@ -163,6 +163,14 @@ public:
163
163
  return root;
164
164
  }
165
165
 
166
+ ClientContext &GetContext() override {
167
+ return root.GetContext();
168
+ }
169
+
170
+ Catalog *GetCatalog() override {
171
+ return root.GetCatalog();
172
+ }
173
+
166
174
  private:
167
175
  Deserializer &root;
168
176
  idx_t remaining_data;
@@ -177,7 +185,7 @@ struct IndexReadOperation {
177
185
 
178
186
  class FieldReader {
179
187
  public:
180
- DUCKDB_API FieldReader(Deserializer &source);
188
+ DUCKDB_API explicit FieldReader(Deserializer &source);
181
189
  DUCKDB_API ~FieldReader();
182
190
 
183
191
  public:
@@ -1,7 +1,7 @@
1
1
  //===----------------------------------------------------------------------===//
2
2
  // DuckDB
3
3
  //
4
- // duckdb/common/http_stats.hpp
4
+ // duckdb/common/http_state.hpp
5
5
  //
6
6
  //
7
7
  //===----------------------------------------------------------------------===//
@@ -15,7 +15,16 @@
15
15
 
16
16
  namespace duckdb {
17
17
 
18
- class HTTPStats {
18
+ struct CachedFile {
19
+ //! Cached Data
20
+ shared_ptr<char> data;
21
+ //! Data capacity
22
+ uint64_t capacity = 0;
23
+ //! If we finished downloading the file
24
+ bool finished = false;
25
+ };
26
+
27
+ class HTTPState {
19
28
  public:
20
29
  atomic<idx_t> head_count {0};
21
30
  atomic<idx_t> get_count {0};
@@ -23,6 +32,10 @@ public:
23
32
  atomic<idx_t> post_count {0};
24
33
  atomic<idx_t> total_bytes_received {0};
25
34
  atomic<idx_t> total_bytes_sent {0};
35
+ //! Mutex to lock when getting the cached file(Parallel Only)
36
+ mutex cached_files_mutex;
37
+ //! In case of fully downloading the file, the cached files of this query
38
+ unordered_map<string, CachedFile> cached_files;
26
39
 
27
40
  void Reset() {
28
41
  head_count = 0;
@@ -31,13 +44,14 @@ public:
31
44
  post_count = 0;
32
45
  total_bytes_received = 0;
33
46
  total_bytes_sent = 0;
47
+ cached_files.clear();
34
48
  }
35
49
 
36
50
  //! helper function to get the HTTP
37
- static HTTPStats *TryGetStats(FileOpener *opener) {
51
+ static HTTPState *TryGetState(FileOpener *opener) {
38
52
  auto client_context = FileOpener::TryGetClientContext(opener);
39
53
  if (client_context) {
40
- return client_context->client_data->http_stats.get();
54
+ return client_context->client_data->http_state.get();
41
55
  }
42
56
  return nullptr;
43
57
  }
@@ -26,14 +26,16 @@ public:
26
26
  void ReadData(data_ptr_t buffer, uint64_t read_size) override;
27
27
  };
28
28
 
29
- class BufferentContextDeserializer : public BufferedDeserializer {
29
+ class BufferedContextDeserializer : public BufferedDeserializer {
30
30
  public:
31
- BufferentContextDeserializer(ClientContext &context_p, data_ptr_t ptr, idx_t data_size)
31
+ BufferedContextDeserializer(ClientContext &context_p, data_ptr_t ptr, idx_t data_size)
32
32
  : BufferedDeserializer(ptr, data_size), context(context_p) {
33
33
  }
34
34
 
35
35
  public:
36
36
  ClientContext &context;
37
+
38
+ ClientContext &GetContext() override;
37
39
  };
38
40
 
39
41
  } // namespace duckdb
@@ -14,14 +14,16 @@ namespace duckdb {
14
14
 
15
15
  class BufferedFileReader : public Deserializer {
16
16
  public:
17
- BufferedFileReader(FileSystem &fs, const char *path, FileLockType lock_type = FileLockType::READ_LOCK,
18
- FileOpener *opener = nullptr);
17
+ BufferedFileReader(FileSystem &fs, const char *path, ClientContext *context,
18
+ FileLockType lock_type = FileLockType::READ_LOCK, FileOpener *opener = nullptr);
19
19
 
20
20
  FileSystem &fs;
21
21
  unique_ptr<data_t[]> data;
22
22
  idx_t offset;
23
23
  idx_t read_data;
24
24
  unique_ptr<FileHandle> handle;
25
+ ClientContext *context;
26
+ Catalog *catalog = nullptr;
25
27
 
26
28
  public:
27
29
  void ReadData(data_ptr_t buffer, uint64_t read_size) override;
@@ -35,6 +37,10 @@ public:
35
37
  void Seek(uint64_t location);
36
38
  uint64_t CurrentOffset();
37
39
 
40
+ ClientContext &GetContext() override;
41
+
42
+ Catalog *GetCatalog() override;
43
+
38
44
  private:
39
45
  idx_t file_size;
40
46
  idx_t total_read;
@@ -8,6 +8,7 @@
8
8
 
9
9
  #pragma once
10
10
 
11
+ #include "duckdb/catalog/catalog.hpp"
11
12
  #include "duckdb/common/common.hpp"
12
13
  #include "duckdb/common/exception.hpp"
13
14
  #include "duckdb/common/vector.hpp"
@@ -21,6 +22,8 @@ private:
21
22
  uint64_t version = 0L;
22
23
 
23
24
  public:
25
+ bool is_query_plan = false;
26
+
24
27
  virtual ~Serializer() {
25
28
  }
26
29
 
@@ -111,6 +114,16 @@ public:
111
114
  //! Reads [read_size] bytes into the buffer
112
115
  virtual void ReadData(data_ptr_t buffer, idx_t read_size) = 0;
113
116
 
117
+ //! Gets the context for the deserializer
118
+ virtual ClientContext &GetContext() {
119
+ throw InternalException("This deserializer does not have a client-context");
120
+ };
121
+
122
+ //! Gets the catalog for the deserializer
123
+ virtual Catalog *GetCatalog() {
124
+ return nullptr;
125
+ };
126
+
114
127
  template <class T>
115
128
  T Read() {
116
129
  T value;
@@ -23,6 +23,20 @@ class Value;
23
23
  class TypeCatalogEntry;
24
24
  class Vector;
25
25
  class ClientContext;
26
+ class FieldWriter;
27
+
28
+ //! Extra Type Info Type
29
+ enum class ExtraTypeInfoType : uint8_t {
30
+ INVALID_TYPE_INFO = 0,
31
+ GENERIC_TYPE_INFO = 1,
32
+ DECIMAL_TYPE_INFO = 2,
33
+ STRING_TYPE_INFO = 3,
34
+ LIST_TYPE_INFO = 4,
35
+ STRUCT_TYPE_INFO = 5,
36
+ ENUM_TYPE_INFO = 6,
37
+ USER_TYPE_INFO = 7,
38
+ AGGREGATE_STATE_TYPE_INFO = 8
39
+ };
26
40
 
27
41
  struct hugeint_t {
28
42
  public:
@@ -297,6 +311,11 @@ struct LogicalType {
297
311
  inline const ExtraTypeInfo *AuxInfo() const {
298
312
  return type_info_.get();
299
313
  }
314
+
315
+ inline shared_ptr<ExtraTypeInfo> GetAuxInfoShrPtr() const {
316
+ return type_info_;
317
+ }
318
+
300
319
  inline void CopyAuxInfo(const LogicalType& other) {
301
320
  type_info_ = other.type_info_;
302
321
  }
@@ -324,6 +343,9 @@ struct LogicalType {
324
343
 
325
344
  //! Serializes a LogicalType to a stand-alone binary blob
326
345
  DUCKDB_API void Serialize(Serializer &serializer) const;
346
+
347
+ DUCKDB_API void SerializeEnumType(Serializer &serializer) const;
348
+
327
349
  //! Deserializes a blob back into an LogicalType
328
350
  DUCKDB_API static LogicalType Deserialize(Deserializer &source);
329
351
 
@@ -349,6 +371,8 @@ struct LogicalType {
349
371
  DUCKDB_API static void SetCatalog(LogicalType &type, TypeCatalogEntry* catalog_entry);
350
372
  DUCKDB_API static TypeCatalogEntry* GetCatalog(const LogicalType &type);
351
373
 
374
+ DUCKDB_API static ExtraTypeInfoType GetExtraTypeInfoType(const ExtraTypeInfo &type);
375
+
352
376
  //! Gets the decimal properties of a numeric type. Fails if the type is not numeric.
353
377
  DUCKDB_API bool GetDecimalProperties(uint8_t &width, uint8_t &scale) const;
354
378
 
@@ -441,12 +465,14 @@ struct UserType{
441
465
  struct EnumType{
442
466
  DUCKDB_API static const string &GetTypeName(const LogicalType &type);
443
467
  DUCKDB_API static int64_t GetPos(const LogicalType &type, const string_t& key);
444
- DUCKDB_API static Vector &GetValuesInsertOrder(const LogicalType &type);
468
+ DUCKDB_API static const Vector &GetValuesInsertOrder(const LogicalType &type);
445
469
  DUCKDB_API static idx_t GetSize(const LogicalType &type);
446
470
  DUCKDB_API static const string GetValue(const Value &val);
447
471
  DUCKDB_API static void SetCatalog(LogicalType &type, TypeCatalogEntry* catalog_entry);
448
472
  DUCKDB_API static TypeCatalogEntry* GetCatalog(const LogicalType &type);
473
+ DUCKDB_API static string GetSchemaName(const LogicalType &type);
449
474
  DUCKDB_API static PhysicalType GetPhysicalType(const LogicalType &type);
475
+ DUCKDB_API static void Serialize(FieldWriter& writer, const ExtraTypeInfo& type_info, bool serialize_internals);
450
476
  };
451
477
 
452
478
  struct StructType {
@@ -87,6 +87,7 @@ public:
87
87
  // we have data left to read from the file
88
88
  // read directly into the buffer
89
89
  auto bytes_read = file_handle->Read((char *)buffer + result_offset, nr_bytes - result_offset);
90
+ file_size = file_handle->GetFileSize();
90
91
  read_position += bytes_read;
91
92
  if (reset_enabled) {
92
93
  // if reset caching is enabled, we need to cache the bytes that we have read
@@ -32,7 +32,18 @@ enum class ArrowDateTimeType : uint8_t {
32
32
  NANOSECONDS = 2,
33
33
  SECONDS = 3,
34
34
  DAYS = 4,
35
- MONTHS = 5
35
+ MONTHS = 5,
36
+ MONTH_DAY_NANO = 6
37
+ };
38
+
39
+ struct ArrowInterval {
40
+ int32_t months;
41
+ int32_t days;
42
+ int64_t nanoseconds;
43
+
44
+ inline bool operator==(const ArrowInterval &rhs) const {
45
+ return this->days == rhs.days && this->months == rhs.months && this->nanoseconds == rhs.nanoseconds;
46
+ }
36
47
  };
37
48
 
38
49
  struct ArrowConvertData {
@@ -11,6 +11,8 @@
11
11
  #include "duckdb/common/enums/operator_result_type.hpp"
12
12
  #include "duckdb/execution/execution_context.hpp"
13
13
  #include "duckdb/function/function.hpp"
14
+ #include "duckdb/planner/bind_context.hpp"
15
+ #include "duckdb/planner/logical_operator.hpp"
14
16
  #include "duckdb/storage/statistics/node_statistics.hpp"
15
17
 
16
18
  #include <functional>
@@ -136,6 +138,7 @@ public:
136
138
 
137
139
  typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, TableFunctionBindInput &input,
138
140
  vector<LogicalType> &return_types, vector<string> &names);
141
+ typedef unique_ptr<TableRef> (*table_function_bind_replace_t)(ClientContext &context, TableFunctionBindInput &input);
139
142
  typedef unique_ptr<GlobalTableFunctionState> (*table_function_init_global_t)(ClientContext &context,
140
143
  TableFunctionInitInput &input);
141
144
  typedef unique_ptr<LocalTableFunctionState> (*table_function_init_local_t)(ExecutionContext &context,
@@ -185,6 +188,11 @@ public:
185
188
  //! This function is used for determining the return type of a table producing function and returning bind data
186
189
  //! The returned FunctionData object should be constant and should not be changed during execution.
187
190
  table_function_bind_t bind;
191
+ //! (Optional) Bind replace function
192
+ //! This function is called before the regular bind function. It allows returning a TableRef will be used to
193
+ //! to generate a logical plan that replaces the LogicalGet of a regularly bound TableFunction. The BindReplace can
194
+ //! also return a nullptr to indicate a regular bind needs to be performed instead.
195
+ table_function_bind_replace_t bind_replace;
188
196
  //! (Optional) global init function
189
197
  //! Initialize the global operator state of the function.
190
198
  //! The global operator state is used to keep track of the progress in the table function and is shared between
@@ -20,7 +20,7 @@ class BufferedFileWriter;
20
20
  class ClientContext;
21
21
  class CatalogSearchPath;
22
22
  class FileOpener;
23
- class HTTPStats;
23
+ class HTTPState;
24
24
  class QueryProfiler;
25
25
  class QueryProfilerHistory;
26
26
  class PreparedStatementData;
@@ -52,8 +52,8 @@ struct ClientData {
52
52
  //! The file opener of the client context
53
53
  unique_ptr<FileOpener> file_opener;
54
54
 
55
- //! Statistics on HTTP traffic
56
- unique_ptr<HTTPStats> http_stats;
55
+ //! HTTP State in this query
56
+ unique_ptr<HTTPState> http_state;
57
57
 
58
58
  //! The file search path
59
59
  string file_search_path;
@@ -47,6 +47,8 @@ public:
47
47
  return result;
48
48
  }
49
49
 
50
+ ClientContext *GetConnection(DatabaseInstance *db);
51
+
50
52
  static ConnectionManager &Get(DatabaseInstance &db);
51
53
  static ConnectionManager &Get(ClientContext &context);
52
54
 
@@ -96,6 +96,7 @@ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
96
96
  {"http_retry_backoff", "httpfs"},
97
97
  {"http_retry_wait_ms", "httpfs"},
98
98
  {"http_timeout", "httpfs"},
99
+ {"force_download", "httpfs"},
99
100
  {"s3_access_key_id", "httpfs"},
100
101
  {"s3_endpoint", "httpfs"},
101
102
  {"s3_region", "httpfs"},
@@ -59,6 +59,9 @@ public:
59
59
  void Serialize(Serializer &serializer) const;
60
60
  virtual void Serialize(FieldWriter &writer) const = 0;
61
61
  static unique_ptr<AlterInfo> Deserialize(Deserializer &source);
62
+ virtual string GetColumnName() const {
63
+ return "";
64
+ };
62
65
 
63
66
  AlterEntryData GetAlterEntryData() const;
64
67
  };
@@ -137,6 +137,9 @@ public:
137
137
  unique_ptr<AlterInfo> Copy() const override;
138
138
  void SerializeAlterTable(FieldWriter &writer) const override;
139
139
  static unique_ptr<AlterInfo> Deserialize(FieldReader &reader, AlterEntryData data);
140
+ string GetColumnName() const override {
141
+ return removed_column;
142
+ };
140
143
  };
141
144
 
142
145
  //===--------------------------------------------------------------------===//
@@ -158,6 +161,9 @@ public:
158
161
  unique_ptr<AlterInfo> Copy() const override;
159
162
  void SerializeAlterTable(FieldWriter &writer) const override;
160
163
  static unique_ptr<AlterInfo> Deserialize(FieldReader &reader, AlterEntryData data);
164
+ string GetColumnName() const override {
165
+ return column_name;
166
+ };
161
167
  };
162
168
 
163
169
  //===--------------------------------------------------------------------===//
@@ -44,7 +44,7 @@ protected:
44
44
  virtual void WriteMacro(ScalarMacroCatalogEntry &table);
45
45
  virtual void WriteTableMacro(TableMacroCatalogEntry &table);
46
46
  virtual void WriteIndex(IndexCatalogEntry &index_catalog);
47
- virtual void WriteType(TypeCatalogEntry &table);
47
+ virtual void WriteType(TypeCatalogEntry &type);
48
48
  };
49
49
 
50
50
  class CheckpointReader {
@@ -36,7 +36,14 @@ public:
36
36
  //! Read content of size read_size into the buffer
37
37
  void ReadData(data_ptr_t buffer, idx_t read_size) override;
38
38
 
39
+ ClientContext &GetContext() override;
40
+ Catalog *GetCatalog() override;
41
+ void SetCatalog(Catalog *catalog_p);
42
+ void SetContext(ClientContext *context_p);
43
+
39
44
  private:
40
45
  void ReadNewBlock(block_id_t id);
46
+ Catalog *catalog = nullptr;
47
+ ClientContext *context = nullptr;
41
48
  };
42
49
  } // namespace duckdb
@@ -137,7 +137,7 @@ public:
137
137
  //! Sets the table used for subsequent insert/delete/update commands
138
138
  void WriteSetTable(string &schema, string &table);
139
139
 
140
- void WriteAlter(AlterInfo &info);
140
+ void WriteAlter(data_ptr_t ptr, idx_t data_size);
141
141
 
142
142
  void WriteInsert(DataChunk &chunk);
143
143
  void WriteDelete(DataChunk &chunk);