duckdb 0.5.2-dev1092.0 → 0.5.2-dev1104.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
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.5.2-dev1092.0",
5
+ "version": "0.5.2-dev1104.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -58640,19 +58640,6 @@ void Construct(vector<Key> &keys, row_t *row_ids, Node *&node, KeySection &key_s
58640
58640
  }
58641
58641
  }
58642
58642
 
58643
- void FindFirstNotNullKey(vector<Key> &keys, bool &skipped_all_nulls, idx_t &start_idx) {
58644
-
58645
- if (!skipped_all_nulls) {
58646
- for (idx_t i = 0; i < keys.size(); i++) {
58647
- if (!keys[i].Empty()) {
58648
- start_idx = i;
58649
- skipped_all_nulls = true;
58650
- return;
58651
- }
58652
- }
58653
- }
58654
- }
58655
-
58656
58643
  void ART::ConstructAndMerge(IndexLock &lock, PayloadScanner &scanner, Allocator &allocator) {
58657
58644
 
58658
58645
  auto payload_types = logical_types;
@@ -58661,7 +58648,6 @@ void ART::ConstructAndMerge(IndexLock &lock, PayloadScanner &scanner, Allocator
58661
58648
  ArenaAllocator arena_allocator(allocator);
58662
58649
  vector<Key> keys(STANDARD_VECTOR_SIZE);
58663
58650
 
58664
- auto skipped_all_nulls = false;
58665
58651
  auto temp_art = make_unique<ART>(this->column_ids, this->table_io_manager, this->unbound_expressions,
58666
58652
  this->constraint_type, this->db);
58667
58653
 
@@ -58686,22 +58672,6 @@ void ART::ConstructAndMerge(IndexLock &lock, PayloadScanner &scanner, Allocator
58686
58672
  arena_allocator.Reset();
58687
58673
  GenerateKeys(arena_allocator, ordered_chunk, keys);
58688
58674
 
58689
- // we order NULLS FIRST, so we might have to skip nulls at the start of our sorted data
58690
- idx_t start_idx = 0;
58691
- FindFirstNotNullKey(keys, skipped_all_nulls, start_idx);
58692
-
58693
- if (start_idx != 0 && IsPrimary()) {
58694
- throw ConstraintException("NULLs in new data violate the primary key constraint of the index");
58695
- }
58696
-
58697
- if (!skipped_all_nulls) {
58698
- if (IsPrimary()) {
58699
- // chunk consists only of NULLs
58700
- throw ConstraintException("NULLs in new data violate the primary key constraint of the index");
58701
- }
58702
- continue;
58703
- }
58704
-
58705
58675
  // prepare the row_identifiers
58706
58676
  row_identifiers.Flatten(ordered_chunk.size());
58707
58677
  auto row_ids = FlatVector::GetData<row_t>(row_identifiers);
@@ -58709,7 +58679,7 @@ void ART::ConstructAndMerge(IndexLock &lock, PayloadScanner &scanner, Allocator
58709
58679
  // construct the ART of this chunk
58710
58680
  auto art = make_unique<ART>(this->column_ids, this->table_io_manager, this->unbound_expressions,
58711
58681
  this->constraint_type, this->db);
58712
- auto key_section = KeySection(start_idx, ordered_chunk.size() - 1, 0, 0);
58682
+ auto key_section = KeySection(0, ordered_chunk.size() - 1, 0, 0);
58713
58683
  auto has_constraint = IsUnique();
58714
58684
  Construct(keys, row_ids, art->tree, key_section, has_constraint);
58715
58685
 
@@ -82706,17 +82676,22 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreate &op
82706
82676
 
82707
82677
 
82708
82678
 
82679
+
82680
+
82681
+
82709
82682
  namespace duckdb {
82710
82683
 
82711
82684
  unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateIndex &op) {
82712
82685
 
82713
82686
  D_ASSERT(op.children.empty());
82714
82687
 
82688
+ // table scan operator for index key columns and row IDs
82715
82689
  unique_ptr<TableFilterSet> table_filters;
82716
82690
  op.info->column_ids.emplace_back(COLUMN_IDENTIFIER_ROW_ID);
82717
82691
 
82718
82692
  auto &bind_data = (TableScanBindData &)*op.bind_data;
82719
82693
  bind_data.is_create_index = true;
82694
+
82720
82695
  auto table_scan =
82721
82696
  make_unique<PhysicalTableScan>(op.info->scan_types, op.function, move(op.bind_data), op.info->column_ids,
82722
82697
  op.info->names, move(table_filters), op.estimated_cardinality);
@@ -82724,10 +82699,32 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateInde
82724
82699
  dependencies.insert(&op.table);
82725
82700
  op.info->column_ids.pop_back();
82726
82701
 
82702
+ D_ASSERT(op.info->scan_types.size() - 1 <= op.info->names.size());
82703
+ D_ASSERT(op.info->scan_types.size() - 1 <= op.info->column_ids.size());
82704
+
82705
+ // filter operator for IS_NOT_NULL on each key column
82706
+ vector<LogicalType> filter_types;
82707
+ vector<unique_ptr<Expression>> filter_select_list;
82708
+
82709
+ for (idx_t i = 0; i < op.info->scan_types.size() - 1; i++) {
82710
+ filter_types.push_back(op.info->scan_types[i]);
82711
+ auto is_not_null_expr =
82712
+ make_unique<BoundOperatorExpression>(ExpressionType::OPERATOR_IS_NOT_NULL, LogicalType::BOOLEAN);
82713
+ auto bound_ref =
82714
+ make_unique<BoundReferenceExpression>(op.info->names[op.info->column_ids[i]], op.info->scan_types[i], i);
82715
+ is_not_null_expr->children.push_back(move(bound_ref));
82716
+ filter_select_list.push_back(move(is_not_null_expr));
82717
+ }
82718
+
82719
+ auto null_filter = make_unique<PhysicalFilter>(move(filter_types), move(filter_select_list), STANDARD_VECTOR_SIZE);
82720
+ null_filter->types.emplace_back(LogicalType::ROW_TYPE);
82721
+ null_filter->children.push_back(move(table_scan));
82722
+
82723
+ // actual physical create index operator
82727
82724
  auto physical_create_index =
82728
82725
  make_unique<PhysicalCreateIndex>(op, op.table, op.info->column_ids, move(op.expressions), move(op.info),
82729
82726
  move(op.unbound_expressions), op.estimated_cardinality);
82730
- physical_create_index->children.push_back(move(table_scan));
82727
+ physical_create_index->children.push_back(move(null_filter));
82731
82728
  return move(physical_create_index);
82732
82729
  }
82733
82730
 
@@ -114079,12 +114076,11 @@ static idx_t LevenshteinDistance(const string_t &txt, const string_t &tgt) {
114079
114076
  auto txt_len = txt.GetSize();
114080
114077
  auto tgt_len = tgt.GetSize();
114081
114078
 
114082
- if (txt_len < 1) {
114083
- throw InvalidInputException("Levenshtein Function: 1st argument too short");
114084
- }
114085
-
114086
- if (tgt_len < 1) {
114087
- throw InvalidInputException("Levenshtein Function: 2nd argument too short");
114079
+ // If one string is empty, the distance equals the length of the other string
114080
+ if (txt_len == 0) {
114081
+ return tgt_len;
114082
+ } else if (tgt_len == 0) {
114083
+ return txt_len;
114088
114084
  }
114089
114085
 
114090
114086
  auto txt_str = txt.GetDataUnsafe();
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 "0060a0f5a"
15
- #define DUCKDB_VERSION "v0.5.2-dev1092"
14
+ #define DUCKDB_SOURCE_ID "b8ed45a8d"
15
+ #define DUCKDB_VERSION "v0.5.2-dev1104"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //