duckdb 0.4.1-dev1562.0 → 0.4.1-dev1570.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.4.1-dev1562.0",
4
+ "version": "0.4.1-dev1570.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -100440,6 +100440,9 @@ void SinkDataChunk(Vector *child_vector, SelectionVector &sel, idx_t offset_list
100440
100440
  payload_chunk.data[0].Reference(payload_vector);
100441
100441
  payload_chunk.SetCardinality(offset_lists_indices);
100442
100442
 
100443
+ key_chunk.Verify();
100444
+ payload_chunk.Verify();
100445
+
100443
100446
  // sink
100444
100447
  local_sort_state.SinkChunk(key_chunk, payload_chunk);
100445
100448
  data_to_sort = true;
@@ -100453,6 +100456,7 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
100453
100456
  result.SetVectorType(VectorType::FLAT_VECTOR);
100454
100457
  auto &result_validity = FlatVector::Validity(result);
100455
100458
 
100459
+ args.Flatten();
100456
100460
  if (lists.GetType().id() == LogicalTypeId::SQLNULL) {
100457
100461
  result_validity.SetInvalid(0);
100458
100462
  return;
@@ -100500,7 +100504,6 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
100500
100504
  bool data_to_sort = false;
100501
100505
 
100502
100506
  for (idx_t i = 0; i < count; i++) {
100503
-
100504
100507
  auto lists_index = lists_data.sel->get_index(i);
100505
100508
  const auto &list_entry = list_entries[lists_index];
100506
100509
 
@@ -100516,7 +100519,6 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
100516
100519
  }
100517
100520
 
100518
100521
  for (idx_t child_idx = 0; child_idx < list_entry.length; child_idx++) {
100519
-
100520
100522
  // lists_indices vector is full, sink
100521
100523
  if (offset_lists_indices == STANDARD_VECTOR_SIZE) {
100522
100524
  SinkDataChunk(&child_vector, sel, offset_lists_indices, info.types, info.payload_types, payload_vector,
@@ -100524,10 +100526,10 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
100524
100526
  offset_lists_indices = 0;
100525
100527
  }
100526
100528
 
100527
- auto source_idx = child_data.sel->get_index(list_entry.offset + child_idx);
100529
+ auto source_idx = list_entry.offset + child_idx;
100528
100530
  sel.set_index(offset_lists_indices, source_idx);
100529
100531
  lists_indices_data[offset_lists_indices] = (uint32_t)i;
100530
- payload_vector_data[offset_lists_indices] = incr_payload_count;
100532
+ payload_vector_data[offset_lists_indices] = source_idx;
100531
100533
  offset_lists_indices++;
100532
100534
  incr_payload_count++;
100533
100535
  }
@@ -100539,7 +100541,6 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
100539
100541
  }
100540
100542
 
100541
100543
  if (data_to_sort) {
100542
-
100543
100544
  // add local state to global state, which sorts the data
100544
100545
  global_sort_state.AddLocalState(local_sort_state);
100545
100546
  global_sort_state.PrepareMergePhase();
@@ -100566,6 +100567,7 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
100566
100567
 
100567
100568
  for (idx_t i = 0; i < row_count; i++) {
100568
100569
  sel_sorted.set_index(sel_sorted_idx, result_data[i]);
100570
+ D_ASSERT(result_data[i] < lists_size);
100569
100571
  sel_sorted_idx++;
100570
100572
  }
100571
100573
  }
@@ -120346,6 +120348,7 @@ duckdb_data_chunk duckdb_result_get_chunk(duckdb_result result, idx_t chunk_idx)
120346
120348
 
120347
120349
 
120348
120350
 
120351
+
120349
120352
  namespace duckdb {
120350
120353
 
120351
120354
  struct CTableFunctionInfo : public TableFunctionInfo {
@@ -120377,6 +120380,7 @@ struct CTableBindData : public TableFunctionData {
120377
120380
  CTableFunctionInfo *info = nullptr;
120378
120381
  void *bind_data = nullptr;
120379
120382
  duckdb_delete_callback_t delete_callback = nullptr;
120383
+ unique_ptr<NodeStatistics> stats;
120380
120384
  };
120381
120385
 
120382
120386
  struct CTableInternalBindInfo {
@@ -120491,6 +120495,14 @@ unique_ptr<LocalTableFunctionState> CTableFunctionLocalInit(ExecutionContext &co
120491
120495
  return move(result);
120492
120496
  }
120493
120497
 
120498
+ unique_ptr<NodeStatistics> CTableFunctionCardinality(ClientContext &context, const FunctionData *bind_data_p) {
120499
+ auto &bind_data = (const CTableBindData &)*bind_data_p;
120500
+ if (!bind_data.stats) {
120501
+ return nullptr;
120502
+ }
120503
+ return make_unique<NodeStatistics>(*bind_data.stats);
120504
+ }
120505
+
120494
120506
  void CTableFunction(ClientContext &context, TableFunctionInput &data_p, DataChunk &output) {
120495
120507
  auto &bind_data = (CTableBindData &)*data_p.bind_data;
120496
120508
  auto &global_data = (CTableGlobalInitData &)*data_p.global_state;
@@ -120511,6 +120523,7 @@ duckdb_table_function duckdb_create_table_function() {
120511
120523
  auto function = new duckdb::TableFunction("", {}, duckdb::CTableFunction, duckdb::CTableFunctionBind,
120512
120524
  duckdb::CTableFunctionInit, duckdb::CTableFunctionLocalInit);
120513
120525
  function->function_info = duckdb::make_shared<duckdb::CTableFunctionInfo>();
120526
+ function->cardinality = duckdb::CTableFunctionCardinality;
120514
120527
  return function;
120515
120528
  }
120516
120529
 
@@ -120659,6 +120672,18 @@ void duckdb_bind_set_bind_data(duckdb_bind_info info, void *bind_data, duckdb_de
120659
120672
  bind_info->bind_data.delete_callback = destroy;
120660
120673
  }
120661
120674
 
120675
+ void duckdb_bind_set_cardinality(duckdb_bind_info info, idx_t cardinality, bool is_exact) {
120676
+ if (!info) {
120677
+ return;
120678
+ }
120679
+ auto bind_info = (duckdb::CTableInternalBindInfo *)info;
120680
+ if (is_exact) {
120681
+ bind_info->bind_data.stats = duckdb::make_unique<duckdb::NodeStatistics>(cardinality);
120682
+ } else {
120683
+ bind_info->bind_data.stats = duckdb::make_unique<duckdb::NodeStatistics>(cardinality, cardinality);
120684
+ }
120685
+ }
120686
+
120662
120687
  void duckdb_bind_set_error(duckdb_bind_info info, const char *error) {
120663
120688
  if (!info || !error) {
120664
120689
  return;
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 "5fdf4a947"
15
- #define DUCKDB_VERSION "v0.4.1-dev1562"
14
+ #define DUCKDB_SOURCE_ID "fce627875"
15
+ #define DUCKDB_VERSION "v0.4.1-dev1570"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -17860,6 +17860,14 @@ Sets the user-provided bind data in the bind object. This object can be retrieve
17860
17860
  */
17861
17861
  DUCKDB_API void duckdb_bind_set_bind_data(duckdb_bind_info info, void *bind_data, duckdb_delete_callback_t destroy);
17862
17862
 
17863
+ /*!
17864
+ Sets the cardinality estimate for the table function, used for optimization.
17865
+
17866
+ * info: The bind data object.
17867
+ * is_exact: Whether or not the cardinality estimate is exact, or an approximation
17868
+ */
17869
+ DUCKDB_API void duckdb_bind_set_cardinality(duckdb_bind_info info, idx_t cardinality, bool is_exact);
17870
+
17863
17871
  /*!
17864
17872
  Report that an error has occurred while calling bind.
17865
17873