duckdb 0.5.1-dev181.0 → 0.5.1-dev201.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.1-dev181.0",
4
+ "version": "0.5.1-dev201.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -80118,10 +80118,17 @@ void PhysicalCreateIndex::GetData(ExecutionContext &context, DataChunk &chunk, G
80118
80118
  return;
80119
80119
  }
80120
80120
 
80121
+ // convert virtual column ids to storage column ids
80122
+ vector<column_t> storage_ids;
80123
+ for (auto &column_id : column_ids) {
80124
+ D_ASSERT(column_id < table.columns.size());
80125
+ storage_ids.push_back(table.columns[column_id].StorageOid());
80126
+ }
80127
+
80121
80128
  unique_ptr<Index> index;
80122
80129
  switch (info->index_type) {
80123
80130
  case IndexType::ART: {
80124
- index = make_unique<ART>(column_ids, unbound_expressions, info->constraint_type, *context.client.db);
80131
+ index = make_unique<ART>(storage_ids, unbound_expressions, info->constraint_type, *context.client.db);
80125
80132
  break;
80126
80133
  }
80127
80134
  default:
@@ -144467,7 +144474,10 @@ FilterResult FilterCombiner::AddBoundComparisonFilter(Expression *expr) {
144467
144474
  auto node = GetNode(left_is_scalar ? comparison.right.get() : comparison.left.get());
144468
144475
  idx_t equivalence_set = GetEquivalenceSet(node);
144469
144476
  auto scalar = left_is_scalar ? comparison.left.get() : comparison.right.get();
144470
- auto constant_value = ExpressionExecutor::EvaluateScalar(*scalar);
144477
+ Value constant_value;
144478
+ if (!ExpressionExecutor::TryEvaluateScalar(*scalar, constant_value)) {
144479
+ return FilterResult::UNSATISFIABLE;
144480
+ }
144471
144481
  if (constant_value.IsNull()) {
144472
144482
  // comparisons with null are always null (i.e. will never result in rows)
144473
144483
  return FilterResult::UNSATISFIABLE;
@@ -144548,7 +144558,11 @@ FilterResult FilterCombiner::AddFilter(Expression *expr) {
144548
144558
  }
144549
144559
  if (expr->IsFoldable()) {
144550
144560
  // scalar condition, evaluate it
144551
- auto result = ExpressionExecutor::EvaluateScalar(*expr).CastAs(LogicalType::BOOLEAN);
144561
+ Value result;
144562
+ if (!ExpressionExecutor::TryEvaluateScalar(*expr, result)) {
144563
+ return FilterResult::UNSUPPORTED;
144564
+ }
144565
+ result = result.CastAs(LogicalType::BOOLEAN);
144552
144566
  // check if the filter passes
144553
144567
  if (result.IsNull() || !BooleanValue::Get(result)) {
144554
144568
  // the filter does not pass the scalar test, create an empty result
@@ -144572,7 +144586,10 @@ FilterResult FilterCombiner::AddFilter(Expression *expr) {
144572
144586
 
144573
144587
  if (lower_is_scalar) {
144574
144588
  auto scalar = comparison.lower.get();
144575
- auto constant_value = ExpressionExecutor::EvaluateScalar(*scalar);
144589
+ Value constant_value;
144590
+ if (!ExpressionExecutor::TryEvaluateScalar(*scalar, constant_value)) {
144591
+ return FilterResult::UNSUPPORTED;
144592
+ }
144576
144593
 
144577
144594
  // create the ExpressionValueInformation
144578
144595
  ExpressionValueInformation info;
@@ -144605,7 +144622,10 @@ FilterResult FilterCombiner::AddFilter(Expression *expr) {
144605
144622
 
144606
144623
  if (upper_is_scalar) {
144607
144624
  auto scalar = comparison.upper.get();
144608
- auto constant_value = ExpressionExecutor::EvaluateScalar(*scalar);
144625
+ Value constant_value;
144626
+ if (!ExpressionExecutor::TryEvaluateScalar(*scalar, constant_value)) {
144627
+ return FilterResult::UNSUPPORTED;
144628
+ }
144609
144629
 
144610
144630
  // create the ExpressionValueInformation
144611
144631
  ExpressionValueInformation info;
@@ -145517,7 +145537,6 @@ unique_ptr<Expression> InClauseRewriter::VisitReplace(BoundOperatorExpression &e
145517
145537
  // IN clause with many children: try to generate a mark join that replaces this IN expression
145518
145538
  // we can only do this if the expressions in the expression list are scalar
145519
145539
  for (idx_t i = 1; i < expr.children.size(); i++) {
145520
- D_ASSERT(expr.children[i]->return_type == in_type);
145521
145540
  if (!expr.children[i]->IsFoldable()) {
145522
145541
  // non-scalar expression
145523
145542
  all_scalar = false;
@@ -167743,7 +167762,7 @@ string QueryNode::ResultModifiersToString() const {
167743
167762
  } else if (modifier.type == ResultModifierType::LIMIT_PERCENT_MODIFIER) {
167744
167763
  auto &limit_p_modifier = (LimitPercentModifier &)modifier;
167745
167764
  if (limit_p_modifier.limit) {
167746
- result += " LIMIT " + limit_p_modifier.limit->ToString() + " %";
167765
+ result += " LIMIT (" + limit_p_modifier.limit->ToString() + ") %";
167747
167766
  }
167748
167767
  if (limit_p_modifier.offset) {
167749
167768
  result += " OFFSET " + limit_p_modifier.offset->ToString();
@@ -175215,6 +175234,8 @@ BindResult SelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFuncti
175215
175234
  // we didn't bind columns, try again in children
175216
175235
  return BindResult(error);
175217
175236
  }
175237
+ } else if (depth > 0 && !aggregate_binder.HasBoundColumns()) {
175238
+ return BindResult("Aggregate with only constant parameters has to be bound in the root subquery");
175218
175239
  }
175219
175240
  if (!filter_error.empty()) {
175220
175241
  return BindResult(filter_error);
@@ -175222,8 +175243,9 @@ BindResult SelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFuncti
175222
175243
 
175223
175244
  if (aggr.filter) {
175224
175245
  auto &child = (BoundExpression &)*aggr.filter;
175225
- bound_filter = move(child.expr);
175246
+ bound_filter = BoundCastExpression::AddCastToType(move(child.expr), LogicalType::BOOLEAN);
175226
175247
  }
175248
+
175227
175249
  // all children bound successfully
175228
175250
  // extract the children and types
175229
175251
  vector<LogicalType> types;
@@ -177251,7 +177273,6 @@ protected:
177251
177273
  BindResult BindExpression(unique_ptr<ParsedExpression> *expr, idx_t depth, bool root_expression = false) override;
177252
177274
 
177253
177275
  string UnsupportedAggregateMessage() override;
177254
- bool CanContainSubqueries() override;
177255
177276
  };
177256
177277
 
177257
177278
  } // namespace duckdb
@@ -177400,10 +177421,13 @@ public:
177400
177421
  public:
177401
177422
  unique_ptr<Expression> Bind(unique_ptr<ParsedExpression> expr);
177402
177423
 
177403
- idx_t MaxCount() {
177424
+ idx_t MaxCount() const {
177404
177425
  return max_count;
177405
177426
  }
177406
177427
 
177428
+ bool HasExtraList() const {
177429
+ return extra_list;
177430
+ }
177407
177431
  unique_ptr<Expression> CreateExtraReference(unique_ptr<ParsedExpression> expr);
177408
177432
 
177409
177433
  private:
@@ -177445,6 +177469,9 @@ unique_ptr<Expression> Binder::BindDelimiter(ClientContext &context, OrderBinder
177445
177469
  Value &delimiter_value) {
177446
177470
  auto new_binder = Binder::CreateBinder(context, this, true);
177447
177471
  if (delimiter->HasSubquery()) {
177472
+ if (!order_binder.HasExtraList()) {
177473
+ throw BinderException("Subquery in LIMIT/OFFSET not supported in set operation");
177474
+ }
177448
177475
  return order_binder.CreateExtraReference(move(delimiter));
177449
177476
  }
177450
177477
  ExpressionBinder expr_binder(*new_binder, context);
@@ -177455,6 +177482,8 @@ unique_ptr<Expression> Binder::BindDelimiter(ClientContext &context, OrderBinder
177455
177482
  delimiter_value = ExpressionExecutor::EvaluateScalar(*expr).CastAs(type);
177456
177483
  return nullptr;
177457
177484
  }
177485
+ // move any correlated columns to this binder
177486
+ MoveCorrelatedExpressions(*new_binder);
177458
177487
  return expr;
177459
177488
  }
177460
177489
 
@@ -185100,7 +185129,7 @@ BindResult ConstantBinder::BindExpression(unique_ptr<ParsedExpression> *expr_ptr
185100
185129
  case ExpressionClass::COLUMN_REF:
185101
185130
  return BindResult(clause + " cannot contain column names");
185102
185131
  case ExpressionClass::SUBQUERY:
185103
- return BindResult(clause + " cannot contain subqueries");
185132
+ throw BinderException(clause + " cannot contain subqueries");
185104
185133
  case ExpressionClass::DEFAULT:
185105
185134
  return BindResult(clause + " cannot contain DEFAULT clause");
185106
185135
  case ExpressionClass::WINDOW:
@@ -185114,10 +185143,6 @@ string ConstantBinder::UnsupportedAggregateMessage() {
185114
185143
  return clause + " cannot contain aggregates!";
185115
185144
  }
185116
185145
 
185117
- bool ConstantBinder::CanContainSubqueries() {
185118
- return false;
185119
- }
185120
-
185121
185146
  } // namespace duckdb
185122
185147
 
185123
185148
 
@@ -185364,6 +185389,9 @@ unique_ptr<Expression> OrderBinder::CreateProjectionReference(ParsedExpression &
185364
185389
  }
185365
185390
 
185366
185391
  unique_ptr<Expression> OrderBinder::CreateExtraReference(unique_ptr<ParsedExpression> expr) {
185392
+ if (!extra_list) {
185393
+ throw InternalException("CreateExtraReference called without extra_list");
185394
+ }
185367
185395
  auto result = CreateProjectionReference(*expr, extra_list->size());
185368
185396
  extra_list->push_back(move(expr));
185369
185397
  return result;
@@ -185919,9 +185947,6 @@ unique_ptr<Expression> ExpressionBinder::Bind(unique_ptr<ParsedExpression> &expr
185919
185947
  // bind the main expression
185920
185948
  auto error_msg = Bind(&expr, 0, root_expression);
185921
185949
  if (!error_msg.empty()) {
185922
- if (!CanContainSubqueries()) {
185923
- throw BinderException(error_msg);
185924
- }
185925
185950
  // failed to bind: try to bind correlated columns in the expression (if any)
185926
185951
  bool success = BindCorrelatedColumns(expr);
185927
185952
  if (!success) {
@@ -185979,10 +186004,6 @@ string ExpressionBinder::Bind(unique_ptr<ParsedExpression> *expr, idx_t depth, b
185979
186004
  return string();
185980
186005
  }
185981
186006
 
185982
- bool ExpressionBinder::CanContainSubqueries() {
185983
- return true;
185984
- }
185985
-
185986
186007
  } // namespace duckdb
185987
186008
 
185988
186009
 
@@ -197358,7 +197379,7 @@ void DataTable::InitializeParallelScan(ClientContext &context, ParallelTableScan
197358
197379
 
197359
197380
  bool DataTable::NextParallelScan(ClientContext &context, ParallelTableScanState &state, TableScanState &scan_state,
197360
197381
  const vector<column_t> &column_ids) {
197361
- while (state.current_row_group) {
197382
+ while (state.current_row_group && state.current_row_group->count > 0) {
197362
197383
  idx_t vector_index;
197363
197384
  idx_t max_row;
197364
197385
  if (ClientConfig::GetConfig(context).verify_parallelism) {
@@ -197372,13 +197393,8 @@ bool DataTable::NextParallelScan(ClientContext &context, ParallelTableScanState
197372
197393
  max_row = state.current_row_group->start + state.current_row_group->count;
197373
197394
  }
197374
197395
  max_row = MinValue<idx_t>(max_row, state.max_row);
197375
- bool need_to_scan;
197376
- if (state.current_row_group->count == 0) {
197377
- need_to_scan = false;
197378
- } else {
197379
- need_to_scan = InitializeScanInRowGroup(scan_state, column_ids, scan_state.table_filters,
197380
- state.current_row_group, vector_index, max_row);
197381
- }
197396
+ bool need_to_scan = InitializeScanInRowGroup(scan_state, column_ids, scan_state.table_filters,
197397
+ state.current_row_group, vector_index, max_row);
197382
197398
  if (ClientConfig::GetConfig(context).verify_parallelism) {
197383
197399
  state.vector_index++;
197384
197400
  if (state.vector_index * STANDARD_VECTOR_SIZE >= state.current_row_group->count) {
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 "548692357"
15
- #define DUCKDB_VERSION "v0.5.1-dev181"
14
+ #define DUCKDB_SOURCE_ID "cb8ebc692"
15
+ #define DUCKDB_VERSION "v0.5.1-dev201"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -15992,7 +15992,6 @@ protected:
15992
15992
 
15993
15993
  virtual string UnsupportedAggregateMessage();
15994
15994
  virtual string UnsupportedUnnestMessage();
15995
- virtual bool CanContainSubqueries();
15996
15995
 
15997
15996
  Binder &binder;
15998
15997
  ClientContext &context;
@@ -27214,8 +27213,8 @@ public:
27214
27213
  return function_name + "(" + entry.children[0]->ToString() + ")";
27215
27214
  }
27216
27215
  } else if (entry.children.size() == 2) {
27217
- return "(" + entry.children[0]->ToString() + " " + function_name + " " + entry.children[1]->ToString() +
27218
- ")";
27216
+ return StringUtil::Format("(%s) %s (%s)", entry.children[0]->ToString(), function_name,
27217
+ entry.children[1]->ToString());
27219
27218
  }
27220
27219
  }
27221
27220
  // standard function call