duckdb 0.3.2-dev1304.0 → 0.3.2-dev1306.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-dev1304.0",
4
+ "version": "0.3.2-dev1306.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -121268,6 +121268,10 @@ unique_ptr<NodeStatistics> StatisticsPropagator::PropagateStatistics(LogicalCros
121268
121268
 
121269
121269
  namespace duckdb {
121270
121270
 
121271
+ static bool IsCompareDistinct(ExpressionType type) {
121272
+ return type == ExpressionType::COMPARE_DISTINCT_FROM || type == ExpressionType::COMPARE_NOT_DISTINCT_FROM;
121273
+ }
121274
+
121271
121275
  bool StatisticsPropagator::ExpressionIsConstant(Expression &expr, const Value &val) {
121272
121276
  if (expr.GetExpressionClass() != ExpressionClass::BOUND_CONSTANT) {
121273
121277
  return false;
@@ -121295,8 +121299,10 @@ void StatisticsPropagator::SetStatisticsNotNull(ColumnBinding binding) {
121295
121299
 
121296
121300
  void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &stats, ExpressionType comparison_type,
121297
121301
  const Value &constant) {
121298
- // any comparison filter removes all null values
121299
- 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
+ }
121300
121306
  if (!stats.type.IsNumeric()) {
121301
121307
  // don't handle non-numeric columns here (yet)
121302
121308
  return;
@@ -121332,9 +121338,11 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &stats, Express
121332
121338
 
121333
121339
  void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseStatistics &rstats,
121334
121340
  ExpressionType comparison_type) {
121335
- // any comparison filter removes all null values
121336
- lstats.validity_stats = make_unique<ValidityStatistics>(false);
121337
- 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
+ }
121338
121346
  D_ASSERT(lstats.type == rstats.type);
121339
121347
  if (!lstats.type.IsNumeric()) {
121340
121348
  // don't handle non-numeric columns here (yet)
@@ -121380,6 +121388,7 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseSt
121380
121388
  }
121381
121389
  break;
121382
121390
  case ExpressionType::COMPARE_EQUAL:
121391
+ case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
121383
121392
  // LEFT = RIGHT
121384
121393
  // only the tightest bounds pass
121385
121394
  // so if we have e.g. left = [-50, 250] and right = [-100, 100]
@@ -121405,10 +121414,11 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseSt
121405
121414
  void StatisticsPropagator::UpdateFilterStatistics(Expression &left, Expression &right, ExpressionType comparison_type) {
121406
121415
  // first check if either side is a bound column ref
121407
121416
  // any column ref involved in a comparison will not be null after the comparison
121408
- if (left.type == ExpressionType::BOUND_COLUMN_REF) {
121417
+ bool compare_distinct = IsCompareDistinct(comparison_type);
121418
+ if (!compare_distinct && left.type == ExpressionType::BOUND_COLUMN_REF) {
121409
121419
  SetStatisticsNotNull(((BoundColumnRefExpression &)left).binding);
121410
121420
  }
121411
- if (right.type == ExpressionType::BOUND_COLUMN_REF) {
121421
+ if (!compare_distinct && right.type == ExpressionType::BOUND_COLUMN_REF) {
121412
121422
  SetStatisticsNotNull(((BoundColumnRefExpression &)right).binding);
121413
121423
  }
121414
121424
  // check if this is a comparison between a constant and a column ref
@@ -153545,8 +153555,9 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153545
153555
  join->children.push_back(move(plan->children[1]));
153546
153556
  return move(join);
153547
153557
  }
153558
+ case LogicalOperatorType::LOGICAL_ANY_JOIN:
153548
153559
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN: {
153549
- auto &join = (LogicalComparisonJoin &)*plan;
153560
+ auto &join = (LogicalJoin &)*plan;
153550
153561
  D_ASSERT(plan->children.size() == 2);
153551
153562
  // check the correlated expressions in the children of the join
153552
153563
  bool left_has_correlation = has_correlated_expressions.find(plan->children[0].get())->second;
@@ -153571,6 +153582,13 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153571
153582
  plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
153572
153583
  return plan;
153573
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
+ }
153574
153592
  } else if (join.join_type == JoinType::MARK) {
153575
153593
  if (right_has_correlation) {
153576
153594
  throw Exception("MARK join with correlation in RHS not supported");
@@ -153586,27 +153604,42 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153586
153604
  }
153587
153605
  // both sides have correlation
153588
153606
  // push into both sides
153589
- // NOTE: for OUTER JOINS it matters what the BASE BINDING is after the join
153590
- // for the LEFT OUTER JOIN, we want the LEFT side to be the base binding after we push
153591
- // because the RIGHT binding might contain NULL values
153592
153607
  plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
153593
153608
  auto left_binding = this->base_binding;
153594
153609
  plan->children[1] = PushDownDependentJoinInternal(move(plan->children[1]));
153595
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
153596
153614
  if (join.join_type == JoinType::LEFT) {
153597
153615
  this->base_binding = left_binding;
153616
+ } else if (join.join_type == JoinType::RIGHT) {
153617
+ this->base_binding = right_binding;
153598
153618
  }
153599
153619
  // add the correlated columns to the join conditions
153600
153620
  for (idx_t i = 0; i < correlated_columns.size(); i++) {
153601
- JoinCondition cond;
153602
-
153603
- cond.left = make_unique<BoundColumnRefExpression>(
153621
+ auto left = make_unique<BoundColumnRefExpression>(
153604
153622
  correlated_columns[i].type, ColumnBinding(left_binding.table_index, left_binding.column_index + i));
153605
- cond.right = make_unique<BoundColumnRefExpression>(
153623
+ auto right = make_unique<BoundColumnRefExpression>(
153606
153624
  correlated_columns[i].type, ColumnBinding(right_binding.table_index, right_binding.column_index + i));
153607
- cond.comparison = ExpressionType::COMPARE_EQUAL;
153608
- cond.null_values_are_equal = true;
153609
- 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
+ }
153610
153643
  }
153611
153644
  // then we replace any correlated expressions with the corresponding entry in the correlated_map
153612
153645
  RewriteCorrelatedExpressions rewriter(right_binding, correlated_map);
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 "180367f93"
15
- #define DUCKDB_VERSION "v0.3.2-dev1304"
14
+ #define DUCKDB_SOURCE_ID "8835c86b4"
15
+ #define DUCKDB_VERSION "v0.3.2-dev1306"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //