duckdb 0.3.2-dev1292.0 → 0.3.2-dev1309.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.2-dev1292.0",
4
+ "version": "0.3.2-dev1309.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -4687,6 +4687,37 @@ data_ptr_t Allocator::ReallocateData(data_ptr_t pointer, idx_t size) {
4687
4687
 
4688
4688
 
4689
4689
 
4690
+
4691
+ //===----------------------------------------------------------------------===//
4692
+ // DuckDB
4693
+ //
4694
+ // duckdb/common/result_arrow_wrapper.hpp
4695
+ //
4696
+ //
4697
+ //===----------------------------------------------------------------------===//
4698
+
4699
+
4700
+
4701
+
4702
+
4703
+
4704
+ namespace duckdb {
4705
+ class ResultArrowArrayStreamWrapper {
4706
+ public:
4707
+ explicit ResultArrowArrayStreamWrapper(unique_ptr<QueryResult> result, idx_t approx_batch_size);
4708
+ ArrowArrayStream stream;
4709
+ unique_ptr<QueryResult> result;
4710
+ std::string last_error;
4711
+ idx_t vectors_per_chunk;
4712
+
4713
+ private:
4714
+ static int MyStreamGetSchema(struct ArrowArrayStream *stream, struct ArrowSchema *out);
4715
+ static int MyStreamGetNext(struct ArrowArrayStream *stream, struct ArrowArray *out);
4716
+ static void MyStreamRelease(struct ArrowArrayStream *stream);
4717
+ static const char *MyStreamGetLastError(struct ArrowArrayStream *stream);
4718
+ };
4719
+ } // namespace duckdb
4720
+
4690
4721
  namespace duckdb {
4691
4722
 
4692
4723
  ArrowSchemaWrapper::~ArrowSchemaWrapper() {
@@ -4737,8 +4768,8 @@ void ArrowArrayStreamWrapper::GetSchema(ArrowSchemaWrapper &schema) {
4737
4768
  // LCOV_EXCL_STOP
4738
4769
  }
4739
4770
 
4740
- unique_ptr<ArrowArrayWrapper> ArrowArrayStreamWrapper::GetNextChunk() {
4741
- auto current_chunk = make_unique<ArrowArrayWrapper>();
4771
+ shared_ptr<ArrowArrayWrapper> ArrowArrayStreamWrapper::GetNextChunk() {
4772
+ auto current_chunk = make_shared<ArrowArrayWrapper>();
4742
4773
  if (arrow_array_stream.get_next(&arrow_array_stream, &current_chunk->arrow_array)) { // LCOV_EXCL_START
4743
4774
  throw InvalidInputException("arrow_scan: get_next failed(): %s", string(GetError()));
4744
4775
  } // LCOV_EXCL_STOP
@@ -30174,7 +30205,29 @@ struct SelCache {
30174
30205
 
30175
30206
 
30176
30207
 
30208
+ //===----------------------------------------------------------------------===//
30209
+ // DuckDB
30210
+ //
30211
+ // duckdb/common/types/arrow_aux_data.hpp
30212
+ //
30213
+ //
30214
+ //===----------------------------------------------------------------------===//
30215
+
30216
+
30217
+
30218
+
30219
+
30220
+
30221
+ namespace duckdb {
30222
+ struct ArrowAuxiliaryData : VectorAuxiliaryData {
30223
+ explicit ArrowAuxiliaryData(shared_ptr<ArrowArrayWrapper> arrow_array_p)
30224
+ : VectorAuxiliaryData(VectorAuxiliaryDataType::ARROW_AUXILIARY), arrow_array(std::move(arrow_array_p)) {
30177
30225
 
30226
+ };
30227
+ ~ArrowAuxiliaryData() override {};
30228
+ shared_ptr<ArrowArrayWrapper> arrow_array;
30229
+ };
30230
+ } // namespace duckdb
30178
30231
 
30179
30232
 
30180
30233
  namespace duckdb {
@@ -30443,6 +30496,7 @@ struct DuckDBArrowArrayHolder {
30443
30496
  vector<DuckDBArrowArrayChildHolder> children = {};
30444
30497
  vector<ArrowArray *> children_ptrs = {};
30445
30498
  array<const void *, 1> buffers = {{nullptr}};
30499
+ vector<shared_ptr<ArrowArrayWrapper>> arrow_original_array;
30446
30500
  };
30447
30501
 
30448
30502
  static void ReleaseDuckDBArrowArray(ArrowArray *array) {
@@ -30869,7 +30923,12 @@ void DataChunk::ToArrowArray(ArrowArray *out_array) {
30869
30923
  InitializeChild(child_holder, size());
30870
30924
  auto &vector = child_holder.vector;
30871
30925
  auto &child = child_holder.array;
30872
-
30926
+ auto vec_buffer = data[col_idx].GetBuffer();
30927
+ if (vec_buffer->GetAuxiliaryData() &&
30928
+ vec_buffer->GetAuxiliaryDataType() == VectorAuxiliaryDataType::ARROW_AUXILIARY) {
30929
+ auto arrow_aux_data = (ArrowAuxiliaryData *)vec_buffer->GetAuxiliaryData();
30930
+ root_holder->arrow_original_array.push_back(arrow_aux_data->arrow_array);
30931
+ }
30873
30932
  //! We could, in theory, output other types of vectors here, currently only FLAT Vectors
30874
30933
  SetArrowChild(child_holder, GetTypes()[col_idx], data[col_idx], size());
30875
30934
  SetChildValidityMask(*vector, child);
@@ -90093,7 +90152,7 @@ struct ArrowScanState : public FunctionOperatorData {
90093
90152
  explicit ArrowScanState(unique_ptr<ArrowArrayWrapper> current_chunk) : chunk(move(current_chunk)) {
90094
90153
  }
90095
90154
  unique_ptr<ArrowArrayStreamWrapper> stream;
90096
- unique_ptr<ArrowArrayWrapper> chunk;
90155
+ shared_ptr<ArrowArrayWrapper> chunk;
90097
90156
  idx_t chunk_offset = 0;
90098
90157
  vector<column_t> column_ids;
90099
90158
  //! Store child vectors for Arrow Dictionary Vectors (col-idx,vector)
@@ -90172,6 +90231,7 @@ private:
90172
90231
 
90173
90232
 
90174
90233
 
90234
+
90175
90235
  #include <map>
90176
90236
 
90177
90237
  namespace duckdb {
@@ -91146,6 +91206,8 @@ void ArrowTableFunction::ArrowToDuckDB(ArrowScanState &scan_state,
91146
91206
  if (array.length != scan_state.chunk->arrow_array.length) {
91147
91207
  throw InvalidInputException("arrow_scan: array length mismatch");
91148
91208
  }
91209
+ output.data[idx].GetBuffer()->SetAuxiliaryData(make_unique<ArrowAuxiliaryData>(scan_state.chunk),
91210
+ VectorAuxiliaryDataType::ARROW_AUXILIARY);
91149
91211
  if (array.dictionary) {
91150
91212
  ColumnArrowToDuckDBDictionary(output.data[idx], array, scan_state, output.size(), arrow_convert_data,
91151
91213
  col_idx, arrow_convert_idx);
@@ -121206,6 +121268,10 @@ unique_ptr<NodeStatistics> StatisticsPropagator::PropagateStatistics(LogicalCros
121206
121268
 
121207
121269
  namespace duckdb {
121208
121270
 
121271
+ static bool IsCompareDistinct(ExpressionType type) {
121272
+ return type == ExpressionType::COMPARE_DISTINCT_FROM || type == ExpressionType::COMPARE_NOT_DISTINCT_FROM;
121273
+ }
121274
+
121209
121275
  bool StatisticsPropagator::ExpressionIsConstant(Expression &expr, const Value &val) {
121210
121276
  if (expr.GetExpressionClass() != ExpressionClass::BOUND_CONSTANT) {
121211
121277
  return false;
@@ -121233,8 +121299,10 @@ void StatisticsPropagator::SetStatisticsNotNull(ColumnBinding binding) {
121233
121299
 
121234
121300
  void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &stats, ExpressionType comparison_type,
121235
121301
  const Value &constant) {
121236
- // any comparison filter removes all null values
121237
- stats.validity_stats = make_unique<ValidityStatistics>(false);
121302
+ // regular comparisons removes all null values
121303
+ if (!IsCompareDistinct(comparison_type)) {
121304
+ stats.validity_stats = make_unique<ValidityStatistics>(false);
121305
+ }
121238
121306
  if (!stats.type.IsNumeric()) {
121239
121307
  // don't handle non-numeric columns here (yet)
121240
121308
  return;
@@ -121270,9 +121338,11 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &stats, Express
121270
121338
 
121271
121339
  void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseStatistics &rstats,
121272
121340
  ExpressionType comparison_type) {
121273
- // any comparison filter removes all null values
121274
- lstats.validity_stats = make_unique<ValidityStatistics>(false);
121275
- rstats.validity_stats = make_unique<ValidityStatistics>(false);
121341
+ // regular comparisons removes all null values
121342
+ if (!IsCompareDistinct(comparison_type)) {
121343
+ lstats.validity_stats = make_unique<ValidityStatistics>(false);
121344
+ rstats.validity_stats = make_unique<ValidityStatistics>(false);
121345
+ }
121276
121346
  D_ASSERT(lstats.type == rstats.type);
121277
121347
  if (!lstats.type.IsNumeric()) {
121278
121348
  // don't handle non-numeric columns here (yet)
@@ -121318,6 +121388,7 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseSt
121318
121388
  }
121319
121389
  break;
121320
121390
  case ExpressionType::COMPARE_EQUAL:
121391
+ case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
121321
121392
  // LEFT = RIGHT
121322
121393
  // only the tightest bounds pass
121323
121394
  // so if we have e.g. left = [-50, 250] and right = [-100, 100]
@@ -121343,10 +121414,11 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseSt
121343
121414
  void StatisticsPropagator::UpdateFilterStatistics(Expression &left, Expression &right, ExpressionType comparison_type) {
121344
121415
  // first check if either side is a bound column ref
121345
121416
  // any column ref involved in a comparison will not be null after the comparison
121346
- if (left.type == ExpressionType::BOUND_COLUMN_REF) {
121417
+ bool compare_distinct = IsCompareDistinct(comparison_type);
121418
+ if (!compare_distinct && left.type == ExpressionType::BOUND_COLUMN_REF) {
121347
121419
  SetStatisticsNotNull(((BoundColumnRefExpression &)left).binding);
121348
121420
  }
121349
- if (right.type == ExpressionType::BOUND_COLUMN_REF) {
121421
+ if (!compare_distinct && right.type == ExpressionType::BOUND_COLUMN_REF) {
121350
121422
  SetStatisticsNotNull(((BoundColumnRefExpression &)right).binding);
121351
121423
  }
121352
121424
  // check if this is a comparison between a constant and a column ref
@@ -153483,8 +153555,9 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153483
153555
  join->children.push_back(move(plan->children[1]));
153484
153556
  return move(join);
153485
153557
  }
153558
+ case LogicalOperatorType::LOGICAL_ANY_JOIN:
153486
153559
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN: {
153487
- auto &join = (LogicalComparisonJoin &)*plan;
153560
+ auto &join = (LogicalJoin &)*plan;
153488
153561
  D_ASSERT(plan->children.size() == 2);
153489
153562
  // check the correlated expressions in the children of the join
153490
153563
  bool left_has_correlation = has_correlated_expressions.find(plan->children[0].get())->second;
@@ -153509,6 +153582,13 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153509
153582
  plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
153510
153583
  return plan;
153511
153584
  }
153585
+ } else if (join.join_type == JoinType::RIGHT) {
153586
+ // left outer join
153587
+ if (!left_has_correlation) {
153588
+ // only right has correlation: push into right
153589
+ plan->children[1] = PushDownDependentJoinInternal(move(plan->children[1]));
153590
+ return plan;
153591
+ }
153512
153592
  } else if (join.join_type == JoinType::MARK) {
153513
153593
  if (right_has_correlation) {
153514
153594
  throw Exception("MARK join with correlation in RHS not supported");
@@ -153524,27 +153604,42 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153524
153604
  }
153525
153605
  // both sides have correlation
153526
153606
  // push into both sides
153527
- // NOTE: for OUTER JOINS it matters what the BASE BINDING is after the join
153528
- // for the LEFT OUTER JOIN, we want the LEFT side to be the base binding after we push
153529
- // because the RIGHT binding might contain NULL values
153530
153607
  plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
153531
153608
  auto left_binding = this->base_binding;
153532
153609
  plan->children[1] = PushDownDependentJoinInternal(move(plan->children[1]));
153533
153610
  auto right_binding = this->base_binding;
153611
+ // NOTE: for OUTER JOINS it matters what the BASE BINDING is after the join
153612
+ // for the LEFT OUTER JOIN, we want the LEFT side to be the base binding after we push
153613
+ // because the RIGHT binding might contain NULL values
153534
153614
  if (join.join_type == JoinType::LEFT) {
153535
153615
  this->base_binding = left_binding;
153616
+ } else if (join.join_type == JoinType::RIGHT) {
153617
+ this->base_binding = right_binding;
153536
153618
  }
153537
153619
  // add the correlated columns to the join conditions
153538
153620
  for (idx_t i = 0; i < correlated_columns.size(); i++) {
153539
- JoinCondition cond;
153540
-
153541
- cond.left = make_unique<BoundColumnRefExpression>(
153621
+ auto left = make_unique<BoundColumnRefExpression>(
153542
153622
  correlated_columns[i].type, ColumnBinding(left_binding.table_index, left_binding.column_index + i));
153543
- cond.right = make_unique<BoundColumnRefExpression>(
153623
+ auto right = make_unique<BoundColumnRefExpression>(
153544
153624
  correlated_columns[i].type, ColumnBinding(right_binding.table_index, right_binding.column_index + i));
153545
- cond.comparison = ExpressionType::COMPARE_EQUAL;
153546
- cond.null_values_are_equal = true;
153547
- join.conditions.push_back(move(cond));
153625
+
153626
+ if (join.type == LogicalOperatorType::LOGICAL_COMPARISON_JOIN) {
153627
+ JoinCondition cond;
153628
+ cond.left = move(left);
153629
+ cond.right = move(right);
153630
+ cond.comparison = ExpressionType::COMPARE_EQUAL;
153631
+ cond.null_values_are_equal = true;
153632
+
153633
+ auto &comparison_join = (LogicalComparisonJoin &)join;
153634
+ comparison_join.conditions.push_back(move(cond));
153635
+ } else {
153636
+ auto &any_join = (LogicalAnyJoin &)join;
153637
+ auto comparison = make_unique<BoundComparisonExpression>(ExpressionType::COMPARE_NOT_DISTINCT_FROM,
153638
+ move(left), move(right));
153639
+ auto conjunction = make_unique<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND,
153640
+ move(comparison), move(any_join.condition));
153641
+ any_join.condition = move(conjunction);
153642
+ }
153548
153643
  }
153549
153644
  // then we replace any correlated expressions with the corresponding entry in the correlated_map
153550
153645
  RewriteCorrelatedExpressions rewriter(right_binding, correlated_map);
@@ -222749,12 +222844,17 @@ static void allocate_new(parser_state *state, size_t n) {
222749
222844
 
222750
222845
  void *palloc(size_t n) {
222751
222846
  // we need to align our pointers for the sanitizer
222752
- auto aligned_n = ((n + 7) / 8) * 8;
222847
+ auto allocate_n = n + sizeof(size_t);
222848
+ auto aligned_n = ((allocate_n + 7) / 8) * 8;
222753
222849
  if (pg_parser_state.malloc_pos + aligned_n > PG_MALLOC_SIZE) {
222754
222850
  allocate_new(&pg_parser_state, aligned_n);
222755
222851
  }
222756
222852
 
222757
- void *ptr = pg_parser_state.malloc_ptrs[pg_parser_state.malloc_ptr_idx - 1] + pg_parser_state.malloc_pos;
222853
+ // store the length of the allocation
222854
+ char *base_ptr = pg_parser_state.malloc_ptrs[pg_parser_state.malloc_ptr_idx - 1] + pg_parser_state.malloc_pos;
222855
+ memcpy(base_ptr, &n, sizeof(size_t));
222856
+ // store the actual pointer
222857
+ char *ptr = (char*) base_ptr + sizeof(size_t);
222758
222858
  memset(ptr, 0, n);
222759
222859
  pg_parser_state.malloc_pos += aligned_n;
222760
222860
  return ptr;
@@ -222867,7 +222967,14 @@ void *palloc0fast(size_t n) { // very fast
222867
222967
  return palloc(n);
222868
222968
  }
222869
222969
  void *repalloc(void *ptr, size_t n) {
222870
- return palloc(n);
222970
+ // get the length of the allocation
222971
+ size_t old_len;
222972
+ char *old_len_ptr = (char *) ptr - sizeof(size_t);
222973
+ memcpy((void *) &old_len, old_len_ptr, sizeof(size_t));
222974
+ // re-allocate and copy the data
222975
+ void *new_buf = palloc(n);
222976
+ memcpy(new_buf, ptr, old_len);
222977
+ return new_buf;
222871
222978
  }
222872
222979
  char *NameListToString(PGList *names) {
222873
222980
  throw std::runtime_error("NameListToString NOT IMPLEMENTED");
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "e6f479f2f"
15
- #define DUCKDB_VERSION "v0.3.2-dev1292"
14
+ #define DUCKDB_SOURCE_ID "9552f65a2"
15
+ #define DUCKDB_VERSION "v0.3.2-dev1309"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -3323,6 +3323,21 @@ enum class VectorBufferType : uint8_t {
3323
3323
  OPAQUE_BUFFER // opaque buffer, can be created for example by the parquet reader
3324
3324
  };
3325
3325
 
3326
+ enum class VectorAuxiliaryDataType : uint8_t {
3327
+ ARROW_AUXILIARY // Holds Arrow Chunks that this vector depends on
3328
+ };
3329
+
3330
+ struct VectorAuxiliaryData {
3331
+ explicit VectorAuxiliaryData(VectorAuxiliaryDataType type_p)
3332
+ : type(type_p) {
3333
+
3334
+ };
3335
+ VectorAuxiliaryDataType type;
3336
+
3337
+ virtual ~VectorAuxiliaryData() {
3338
+ }
3339
+ };
3340
+
3326
3341
  //! The VectorBuffer is a class used by the vector to hold its data
3327
3342
  class VectorBuffer {
3328
3343
  public:
@@ -3345,10 +3360,19 @@ public:
3345
3360
  data_ptr_t GetData() {
3346
3361
  return data.get();
3347
3362
  }
3363
+
3348
3364
  void SetData(unique_ptr<data_t[]> new_data) {
3349
3365
  data = move(new_data);
3350
3366
  }
3351
3367
 
3368
+ VectorAuxiliaryData *GetAuxiliaryData() {
3369
+ return aux_data.get();
3370
+ }
3371
+
3372
+ void SetAuxiliaryData(unique_ptr<VectorAuxiliaryData> aux_data_p, VectorAuxiliaryDataType aux_type_p) {
3373
+ aux_data = move(aux_data_p);
3374
+ }
3375
+
3352
3376
  static buffer_ptr<VectorBuffer> CreateStandardVector(PhysicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3353
3377
  static buffer_ptr<VectorBuffer> CreateConstantVector(PhysicalType type);
3354
3378
  static buffer_ptr<VectorBuffer> CreateConstantVector(const LogicalType &logical_type);
@@ -3359,8 +3383,13 @@ public:
3359
3383
  return buffer_type;
3360
3384
  }
3361
3385
 
3386
+ inline VectorAuxiliaryDataType GetAuxiliaryDataType() const {
3387
+ return aux_data->type;
3388
+ }
3389
+
3362
3390
  protected:
3363
3391
  VectorBufferType buffer_type;
3392
+ unique_ptr<VectorAuxiliaryData> aux_data;
3364
3393
  unique_ptr<data_t[]> data;
3365
3394
  };
3366
3395
 
@@ -3846,6 +3875,141 @@ struct SequenceVector {
3846
3875
 
3847
3876
 
3848
3877
 
3878
+ //===----------------------------------------------------------------------===//
3879
+ // DuckDB
3880
+ //
3881
+ // duckdb/common/arrow_wrapper.hpp
3882
+ //
3883
+ //
3884
+ //===----------------------------------------------------------------------===//
3885
+
3886
+
3887
+ //===----------------------------------------------------------------------===//
3888
+ // DuckDB
3889
+ //
3890
+ // duckdb/common/arrow.hpp
3891
+ //
3892
+ //
3893
+ //===----------------------------------------------------------------------===//
3894
+
3895
+ #ifndef ARROW_FLAG_DICTIONARY_ORDERED
3896
+
3897
+ #include <stdint.h>
3898
+
3899
+ #ifdef __cplusplus
3900
+ extern "C" {
3901
+ #endif
3902
+
3903
+ #define ARROW_FLAG_DICTIONARY_ORDERED 1
3904
+ #define ARROW_FLAG_NULLABLE 2
3905
+ #define ARROW_FLAG_MAP_KEYS_SORTED 4
3906
+
3907
+ struct ArrowSchema {
3908
+ // Array type description
3909
+ const char *format;
3910
+ const char *name;
3911
+ const char *metadata;
3912
+ int64_t flags;
3913
+ int64_t n_children;
3914
+ struct ArrowSchema **children;
3915
+ struct ArrowSchema *dictionary;
3916
+
3917
+ // Release callback
3918
+ void (*release)(struct ArrowSchema *);
3919
+ // Opaque producer-specific data
3920
+ void *private_data;
3921
+ };
3922
+
3923
+ struct ArrowArray {
3924
+ // Array data description
3925
+ int64_t length;
3926
+ int64_t null_count;
3927
+ int64_t offset;
3928
+ int64_t n_buffers;
3929
+ int64_t n_children;
3930
+ const void **buffers;
3931
+ struct ArrowArray **children;
3932
+ struct ArrowArray *dictionary;
3933
+
3934
+ // Release callback
3935
+ void (*release)(struct ArrowArray *);
3936
+ // Opaque producer-specific data
3937
+ void *private_data;
3938
+ };
3939
+
3940
+ // EXPERIMENTAL
3941
+ struct ArrowArrayStream {
3942
+ // Callback to get the stream type
3943
+ // (will be the same for all arrays in the stream).
3944
+ // Return value: 0 if successful, an `errno`-compatible error code otherwise.
3945
+ int (*get_schema)(struct ArrowArrayStream *, struct ArrowSchema *out);
3946
+ // Callback to get the next array
3947
+ // (if no error and the array is released, the stream has ended)
3948
+ // Return value: 0 if successful, an `errno`-compatible error code otherwise.
3949
+ int (*get_next)(struct ArrowArrayStream *, struct ArrowArray *out);
3950
+
3951
+ // Callback to get optional detailed error information.
3952
+ // This must only be called if the last stream operation failed
3953
+ // with a non-0 return code. The returned pointer is only valid until
3954
+ // the next operation on this stream (including release).
3955
+ // If unavailable, NULL is returned.
3956
+ const char *(*get_last_error)(struct ArrowArrayStream *);
3957
+
3958
+ // Release callback: release the stream's own resources.
3959
+ // Note that arrays returned by `get_next` must be individually released.
3960
+ void (*release)(struct ArrowArrayStream *);
3961
+ // Opaque producer-specific data
3962
+ void *private_data;
3963
+ };
3964
+
3965
+ #ifdef __cplusplus
3966
+ }
3967
+ #endif
3968
+
3969
+ #endif
3970
+
3971
+
3972
+
3973
+ //! Here we have the internal duckdb classes that interact with Arrow's Internal Header (i.e., duckdb/commons/arrow.hpp)
3974
+ namespace duckdb {
3975
+ class ArrowSchemaWrapper {
3976
+ public:
3977
+ ArrowSchema arrow_schema;
3978
+
3979
+ ArrowSchemaWrapper() {
3980
+ arrow_schema.release = nullptr;
3981
+ }
3982
+
3983
+ ~ArrowSchemaWrapper();
3984
+ };
3985
+ class ArrowArrayWrapper {
3986
+ public:
3987
+ ArrowArray arrow_array;
3988
+ ArrowArrayWrapper() {
3989
+ arrow_array.length = 0;
3990
+ arrow_array.release = nullptr;
3991
+ }
3992
+ ~ArrowArrayWrapper();
3993
+ };
3994
+
3995
+ class ArrowArrayStreamWrapper {
3996
+ public:
3997
+ ArrowArrayStream arrow_array_stream;
3998
+ int64_t number_of_rows;
3999
+ void GetSchema(ArrowSchemaWrapper &schema);
4000
+
4001
+ shared_ptr<ArrowArrayWrapper> GetNextChunk();
4002
+
4003
+ const char *GetError();
4004
+
4005
+ ~ArrowArrayStreamWrapper();
4006
+ ArrowArrayStreamWrapper() {
4007
+ arrow_array_stream.release = nullptr;
4008
+ }
4009
+ };
4010
+ } // namespace duckdb
4011
+
4012
+
3849
4013
  struct ArrowArray;
3850
4014
 
3851
4015
  namespace duckdb {
@@ -12871,89 +13035,6 @@ private:
12871
13035
  //===----------------------------------------------------------------------===//
12872
13036
  // DuckDB
12873
13037
  //
12874
- // duckdb/common/arrow.hpp
12875
- //
12876
- //
12877
- //===----------------------------------------------------------------------===//
12878
-
12879
- #ifndef ARROW_FLAG_DICTIONARY_ORDERED
12880
-
12881
- #include <stdint.h>
12882
-
12883
- #ifdef __cplusplus
12884
- extern "C" {
12885
- #endif
12886
-
12887
- #define ARROW_FLAG_DICTIONARY_ORDERED 1
12888
- #define ARROW_FLAG_NULLABLE 2
12889
- #define ARROW_FLAG_MAP_KEYS_SORTED 4
12890
-
12891
- struct ArrowSchema {
12892
- // Array type description
12893
- const char *format;
12894
- const char *name;
12895
- const char *metadata;
12896
- int64_t flags;
12897
- int64_t n_children;
12898
- struct ArrowSchema **children;
12899
- struct ArrowSchema *dictionary;
12900
-
12901
- // Release callback
12902
- void (*release)(struct ArrowSchema *);
12903
- // Opaque producer-specific data
12904
- void *private_data;
12905
- };
12906
-
12907
- struct ArrowArray {
12908
- // Array data description
12909
- int64_t length;
12910
- int64_t null_count;
12911
- int64_t offset;
12912
- int64_t n_buffers;
12913
- int64_t n_children;
12914
- const void **buffers;
12915
- struct ArrowArray **children;
12916
- struct ArrowArray *dictionary;
12917
-
12918
- // Release callback
12919
- void (*release)(struct ArrowArray *);
12920
- // Opaque producer-specific data
12921
- void *private_data;
12922
- };
12923
-
12924
- // EXPERIMENTAL
12925
- struct ArrowArrayStream {
12926
- // Callback to get the stream type
12927
- // (will be the same for all arrays in the stream).
12928
- // Return value: 0 if successful, an `errno`-compatible error code otherwise.
12929
- int (*get_schema)(struct ArrowArrayStream *, struct ArrowSchema *out);
12930
- // Callback to get the next array
12931
- // (if no error and the array is released, the stream has ended)
12932
- // Return value: 0 if successful, an `errno`-compatible error code otherwise.
12933
- int (*get_next)(struct ArrowArrayStream *, struct ArrowArray *out);
12934
-
12935
- // Callback to get optional detailed error information.
12936
- // This must only be called if the last stream operation failed
12937
- // with a non-0 return code. The returned pointer is only valid until
12938
- // the next operation on this stream (including release).
12939
- // If unavailable, NULL is returned.
12940
- const char *(*get_last_error)(struct ArrowArrayStream *);
12941
-
12942
- // Release callback: release the stream's own resources.
12943
- // Note that arrays returned by `get_next` must be individually released.
12944
- void (*release)(struct ArrowArrayStream *);
12945
- // Opaque producer-specific data
12946
- void *private_data;
12947
- };
12948
-
12949
- #ifdef __cplusplus
12950
- }
12951
- #endif
12952
-
12953
- #endif
12954
- //===----------------------------------------------------------------------===//
12955
- // DuckDB
12956
- //
12957
13038
  // duckdb/common/types/blob.hpp
12958
13039
  //
12959
13040
  //
@@ -20855,73 +20936,6 @@ public:
20855
20936
  string ToString(const string &column_name) override;
20856
20937
  };
20857
20938
 
20858
- } // namespace duckdb
20859
- //===----------------------------------------------------------------------===//
20860
- // DuckDB
20861
- //
20862
- // duckdb/common/arrow_wrapper.hpp
20863
- //
20864
- //
20865
- //===----------------------------------------------------------------------===//
20866
-
20867
-
20868
-
20869
-
20870
-
20871
-
20872
- //! Here we have the internal duckdb classes that interact with Arrow's Internal Header (i.e., duckdb/commons/arrow.hpp)
20873
- namespace duckdb {
20874
- class ArrowSchemaWrapper {
20875
- public:
20876
- ArrowSchema arrow_schema;
20877
-
20878
- ArrowSchemaWrapper() {
20879
- arrow_schema.release = nullptr;
20880
- }
20881
-
20882
- ~ArrowSchemaWrapper();
20883
- };
20884
- class ArrowArrayWrapper {
20885
- public:
20886
- ArrowArray arrow_array;
20887
- ArrowArrayWrapper() {
20888
- arrow_array.length = 0;
20889
- arrow_array.release = nullptr;
20890
- }
20891
- ~ArrowArrayWrapper();
20892
- };
20893
-
20894
- class ArrowArrayStreamWrapper {
20895
- public:
20896
- ArrowArrayStream arrow_array_stream;
20897
- int64_t number_of_rows;
20898
- void GetSchema(ArrowSchemaWrapper &schema);
20899
-
20900
- unique_ptr<ArrowArrayWrapper> GetNextChunk();
20901
-
20902
- const char *GetError();
20903
-
20904
- ~ArrowArrayStreamWrapper();
20905
- ArrowArrayStreamWrapper() {
20906
- arrow_array_stream.release = nullptr;
20907
- }
20908
- };
20909
-
20910
- class ResultArrowArrayStreamWrapper {
20911
- public:
20912
- explicit ResultArrowArrayStreamWrapper(unique_ptr<QueryResult> result, idx_t approx_batch_size);
20913
- ArrowArrayStream stream;
20914
- unique_ptr<QueryResult> result;
20915
- std::string last_error;
20916
- idx_t vectors_per_chunk;
20917
-
20918
- private:
20919
- static int MyStreamGetSchema(struct ArrowArrayStream *stream, struct ArrowSchema *out);
20920
- static int MyStreamGetNext(struct ArrowArrayStream *stream, struct ArrowArray *out);
20921
- static void MyStreamRelease(struct ArrowArrayStream *stream);
20922
- static const char *MyStreamGetLastError(struct ArrowArrayStream *stream);
20923
- };
20924
-
20925
20939
  } // namespace duckdb
20926
20940
  //===----------------------------------------------------------------------===//
20927
20941
  // DuckDB