duckdb 0.5.2-dev456.0 → 0.5.2-dev472.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.5.2-dev456.0",
4
+ "version": "0.5.2-dev472.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -34111,7 +34111,7 @@ static void HeapScatterListVector(Vector &v, idx_t vcount, const SelectionVector
34111
34111
 
34112
34112
  // serialize list validity
34113
34113
  for (idx_t entry_idx = 0; entry_idx < next; entry_idx++) {
34114
- auto list_idx = list_vdata.sel->get_index(entry_idx) + entry_offset;
34114
+ auto list_idx = list_vdata.sel->get_index(entry_idx + entry_offset);
34115
34115
  if (!list_vdata.validity.RowIsValid(list_idx)) {
34116
34116
  *(list_validitymask_location) &= ~(1UL << entry_offset_in_byte);
34117
34117
  }
@@ -177147,6 +177147,8 @@ struct BoundGroupInformation {
177147
177147
  //! The SELECT binder is responsible for binding an expression within the SELECT clause of a SQL statement
177148
177148
  class SelectBinder : public ExpressionBinder {
177149
177149
  public:
177150
+ SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
177151
+ case_insensitive_map_t<idx_t> alias_map);
177150
177152
  SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info);
177151
177153
 
177152
177154
  bool BoundAggregates() {
@@ -177170,8 +177172,10 @@ protected:
177170
177172
 
177171
177173
  BoundSelectNode &node;
177172
177174
  BoundGroupInformation &info;
177175
+ case_insensitive_map_t<idx_t> alias_map;
177173
177176
 
177174
177177
  protected:
177178
+ BindResult BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth);
177175
177179
  BindResult BindGroupingFunction(OperatorExpression &op, idx_t depth) override;
177176
177180
  BindResult BindWindow(WindowExpression &expr, idx_t depth);
177177
177181
 
@@ -179974,7 +179978,7 @@ unique_ptr<BoundQueryNode> Binder::BindNode(SelectNode &statement) {
179974
179978
  }
179975
179979
 
179976
179980
  // after that, we bind to the SELECT list
179977
- SelectBinder select_binder(*this, context, *result, info);
179981
+ SelectBinder select_binder(*this, context, *result, info, alias_map);
179978
179982
  vector<LogicalType> internal_sql_types;
179979
179983
  for (idx_t i = 0; i < statement.select_list.size(); i++) {
179980
179984
  bool is_window = statement.select_list[i]->IsWindow();
@@ -187875,8 +187879,13 @@ BindResult ReturningBinder::BindExpression(unique_ptr<ParsedExpression> *expr_pt
187875
187879
 
187876
187880
  namespace duckdb {
187877
187881
 
187882
+ SelectBinder::SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info,
187883
+ case_insensitive_map_t<idx_t> alias_map)
187884
+ : ExpressionBinder(binder, context), inside_window(false), node(node), info(info), alias_map(move(alias_map)) {
187885
+ }
187886
+
187878
187887
  SelectBinder::SelectBinder(Binder &binder, ClientContext &context, BoundSelectNode &node, BoundGroupInformation &info)
187879
- : ExpressionBinder(binder, context), inside_window(false), node(node), info(info) {
187888
+ : SelectBinder(binder, context, node, info, case_insensitive_map_t<idx_t>()) {
187880
187889
  }
187881
187890
 
187882
187891
  BindResult SelectBinder::BindExpression(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth, bool root_expression) {
@@ -187887,6 +187896,8 @@ BindResult SelectBinder::BindExpression(unique_ptr<ParsedExpression> *expr_ptr,
187887
187896
  return BindGroup(expr, depth, group_index);
187888
187897
  }
187889
187898
  switch (expr.expression_class) {
187899
+ case ExpressionClass::COLUMN_REF:
187900
+ return BindColumnRef(expr_ptr, depth);
187890
187901
  case ExpressionClass::DEFAULT:
187891
187902
  return BindResult("SELECT clause cannot contain DEFAULT clause");
187892
187903
  case ExpressionClass::WINDOW:
@@ -187923,6 +187934,37 @@ idx_t SelectBinder::TryBindGroup(ParsedExpression &expr, idx_t depth) {
187923
187934
  return DConstants::INVALID_INDEX;
187924
187935
  }
187925
187936
 
187937
+ BindResult SelectBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth) {
187938
+ // first try to bind the column reference regularly
187939
+ auto result = ExpressionBinder::BindExpression(expr_ptr, depth);
187940
+ if (!result.HasError()) {
187941
+ return result;
187942
+ }
187943
+ // binding failed
187944
+ // check in the alias map
187945
+ auto &colref = (ColumnRefExpression &)**expr_ptr;
187946
+ if (!colref.IsQualified()) {
187947
+ auto alias_entry = alias_map.find(colref.column_names[0]);
187948
+ if (alias_entry != alias_map.end()) {
187949
+ // found entry!
187950
+ auto index = alias_entry->second;
187951
+ if (index >= node.select_list.size()) {
187952
+ throw BinderException("Column \"%s\" referenced that exists in the SELECT clause - but this column "
187953
+ "cannot be referenced before it is defined",
187954
+ colref.column_names[0]);
187955
+ }
187956
+ if (node.select_list[index]->HasSideEffects()) {
187957
+ throw BinderException("Alias \"%s\" referenced in a SELECT clause - but the expression has side "
187958
+ "effects. This is not yet supported.",
187959
+ colref.column_names[0]);
187960
+ }
187961
+ return BindResult(node.select_list[index]->Copy());
187962
+ }
187963
+ }
187964
+ // entry was not found in the alias map: return the original error
187965
+ return result;
187966
+ }
187967
+
187926
187968
  BindResult SelectBinder::BindGroupingFunction(OperatorExpression &op, idx_t depth) {
187927
187969
  if (op.children.empty()) {
187928
187970
  throw InternalException("GROUPING requires at least one child");
@@ -200278,8 +200320,9 @@ void DataTable::ScanTableSegment(idx_t row_start, idx_t count, const std::functi
200278
200320
 
200279
200321
  CreateIndexScanState state;
200280
200322
 
200281
- idx_t row_start_aligned = row_start / STANDARD_VECTOR_SIZE * STANDARD_VECTOR_SIZE;
200282
- InitializeScanWithOffset(state, column_ids, row_start_aligned, row_start + count);
200323
+ InitializeScanWithOffset(state, column_ids, row_start, row_start + count);
200324
+ auto row_start_aligned = state.table_state.row_group_state.row_group->start +
200325
+ state.table_state.row_group_state.vector_index * STANDARD_VECTOR_SIZE;
200283
200326
 
200284
200327
  idx_t current_row = row_start_aligned;
200285
200328
  while (current_row < end) {
@@ -201016,6 +201059,9 @@ bool LocalStorage::ScanTableStorage(DataTable &table, LocalTableStorage &storage
201016
201059
  }
201017
201060
 
201018
201061
  void LocalStorage::Flush(DataTable &table, LocalTableStorage &storage) {
201062
+ // bulk append threshold: a full row group
201063
+ static constexpr const idx_t MERGE_THRESHOLD = RowGroup::ROW_GROUP_SIZE;
201064
+
201019
201065
  auto storage_entry = move(table_storage[&table]);
201020
201066
  table_storage[&table].reset();
201021
201067
 
@@ -201026,8 +201072,10 @@ void LocalStorage::Flush(DataTable &table, LocalTableStorage &storage) {
201026
201072
 
201027
201073
  TableAppendState append_state;
201028
201074
  table.AppendLock(append_state);
201029
- if (append_state.row_start == 0 && storage.table.info->indexes.Empty() && storage.deleted_rows == 0) {
201030
- // table is currently empty: move over the storage directly
201075
+ if ((append_state.row_start == 0 || storage.row_groups->GetTotalRows() >= MERGE_THRESHOLD) &&
201076
+ storage.table.info->indexes.Empty() && storage.deleted_rows == 0) {
201077
+ // table is currently empty OR we are bulk appending to a table with existing storage: move over the storage
201078
+ // directly
201031
201079
  table.MergeStorage(*storage.row_groups, storage.indexes, storage.stats);
201032
201080
  } else {
201033
201081
  bool constraint_violated = false;
@@ -205068,6 +205116,9 @@ void ListColumnData::Skip(ColumnScanState &state, idx_t count) {
205068
205116
  auto &first_entry = data[0];
205069
205117
  auto &last_entry = data[scan_count - 1];
205070
205118
  idx_t child_scan_count = last_entry.offset + last_entry.length - first_entry.offset;
205119
+ if (child_scan_count == 0) {
205120
+ return;
205121
+ }
205071
205122
 
205072
205123
  // skip the child state forward by the child_scan_count
205073
205124
  child_column->Skip(state.child_states[1], child_scan_count);
@@ -206517,7 +206568,7 @@ void RowGroupCollection::RevertAppendInternal(idx_t start_row, idx_t count) {
206517
206568
 
206518
206569
  void RowGroupCollection::MergeStorage(RowGroupCollection &data) {
206519
206570
  D_ASSERT(data.types == types);
206520
- auto index = row_start;
206571
+ auto index = row_start + total_rows.load();
206521
206572
  for (auto segment = data.row_groups->GetRootSegment(); segment; segment = segment->next.get()) {
206522
206573
  auto &row_group = (RowGroup &)*segment;
206523
206574
  auto new_group = make_unique<RowGroup>(row_group, index);
@@ -206568,15 +206619,16 @@ void RowGroupCollection::Update(TransactionData transaction, row_t *ids, const v
206568
206619
  auto row_group = (RowGroup *)row_groups->GetSegment(ids[pos]);
206569
206620
  row_t base_id =
206570
206621
  row_group->start + ((ids[pos] - row_group->start) / STANDARD_VECTOR_SIZE * STANDARD_VECTOR_SIZE);
206622
+ row_t max_id = MinValue<row_t>(base_id + STANDARD_VECTOR_SIZE, row_group->start + row_group->count);
206571
206623
  for (pos++; pos < updates.size(); pos++) {
206572
206624
  D_ASSERT(ids[pos] >= 0);
206573
- // check if this id still belongs to this vector
206625
+ // check if this id still belongs to this vector in this row group
206574
206626
  if (ids[pos] < base_id) {
206575
206627
  // id is before vector start -> it does not
206576
206628
  break;
206577
206629
  }
206578
- if (ids[pos] >= base_id + STANDARD_VECTOR_SIZE) {
206579
- // id is after vector end -> it does not
206630
+ if (ids[pos] >= max_id) {
206631
+ // id is after the maximum id in this vector -> it does not
206580
206632
  break;
206581
206633
  }
206582
206634
  }
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 "2198368ee"
15
- #define DUCKDB_VERSION "v0.5.2-dev456"
14
+ #define DUCKDB_SOURCE_ID "bd8c9a162"
15
+ #define DUCKDB_VERSION "v0.5.2-dev472"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //