duckdb 0.3.2-dev1304.0 → 0.3.2-dev1316.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-dev1316.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -3101,7 +3101,15 @@ string TableCatalogEntry::ToSQL() {
3101
3101
  ss << ", ";
3102
3102
  }
3103
3103
  auto &column = columns[i];
3104
- ss << KeywordHelper::WriteOptionallyQuoted(column.name) << " " << column.type.ToString();
3104
+ ss << KeywordHelper::WriteOptionallyQuoted(column.name) << " ";
3105
+ switch (column.type.id()) {
3106
+ case LogicalTypeId::ENUM:
3107
+ ss << KeywordHelper::WriteOptionallyQuoted(column.type.ToString());
3108
+ break;
3109
+ default:
3110
+ ss << column.type.ToString();
3111
+ break;
3112
+ }
3105
3113
  bool not_null = not_null_columns.find(column.oid) != not_null_columns.end();
3106
3114
  bool is_single_key_pk = pk_columns.find(column.oid) != pk_columns.end();
3107
3115
  bool is_multi_key_pk = multi_key_pks.find(column.name) != multi_key_pks.end();
@@ -3209,6 +3217,7 @@ TableFunctionCatalogEntry::TableFunctionCatalogEntry(Catalog *catalog, SchemaCat
3209
3217
 
3210
3218
 
3211
3219
 
3220
+
3212
3221
  #include <algorithm>
3213
3222
  #include <sstream>
3214
3223
 
@@ -3245,7 +3254,7 @@ string TypeCatalogEntry::ToSQL() {
3245
3254
  Vector values_insert_order(EnumType::GetValuesInsertOrder(user_type));
3246
3255
  idx_t size = EnumType::GetSize(user_type);
3247
3256
  ss << "CREATE TYPE ";
3248
- ss << name;
3257
+ ss << KeywordHelper::WriteOptionallyQuoted(name);
3249
3258
  ss << " AS ENUM ( ";
3250
3259
 
3251
3260
  for (idx_t i = 0; i < size; i++) {
@@ -57313,11 +57322,11 @@ void BufferedCSVReader::InitParseChunk(idx_t num_cols) {
57313
57322
  void BufferedCSVReader::JumpToBeginning(idx_t skip_rows = 0, bool skip_header = false) {
57314
57323
  ResetBuffer();
57315
57324
  ResetStream();
57316
- SkipRowsAndReadHeader(skip_rows, skip_header);
57317
57325
  sample_chunk_idx = 0;
57318
57326
  bytes_in_chunk = 0;
57319
57327
  end_of_file_reached = false;
57320
57328
  bom_checked = false;
57329
+ SkipRowsAndReadHeader(skip_rows, skip_header);
57321
57330
  }
57322
57331
 
57323
57332
  void BufferedCSVReader::SkipRowsAndReadHeader(idx_t skip_rows, bool skip_header) {
@@ -80656,17 +80665,11 @@ static void ArraySliceFunction(DataChunk &args, ExpressionState &state, Vector &
80656
80665
  D_ASSERT(args.data.size() == 3);
80657
80666
  auto count = args.size();
80658
80667
 
80659
- result.SetVectorType(VectorType::CONSTANT_VECTOR);
80660
- for (idx_t i = 0; i < args.ColumnCount(); i++) {
80661
- if (args.data[i].GetVectorType() != VectorType::CONSTANT_VECTOR) {
80662
- result.SetVectorType(VectorType::FLAT_VECTOR);
80663
- }
80664
- }
80665
-
80666
80668
  Vector &s = args.data[0];
80667
80669
  Vector &b = args.data[1];
80668
80670
  Vector &e = args.data[2];
80669
80671
 
80672
+ s.Normalify(count);
80670
80673
  switch (result.GetType().id()) {
80671
80674
  case LogicalTypeId::LIST:
80672
80675
  // Share the value dictionary as we are just going to slice it
@@ -80679,6 +80682,14 @@ static void ArraySliceFunction(DataChunk &args, ExpressionState &state, Vector &
80679
80682
  default:
80680
80683
  throw NotImplementedException("Specifier type not implemented");
80681
80684
  }
80685
+
80686
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
80687
+ for (idx_t i = 0; i < args.ColumnCount(); i++) {
80688
+ if (args.data[i].GetVectorType() != VectorType::CONSTANT_VECTOR) {
80689
+ result.SetVectorType(VectorType::FLAT_VECTOR);
80690
+ break;
80691
+ }
80692
+ }
80682
80693
  }
80683
80694
 
80684
80695
  static unique_ptr<FunctionData> ArraySliceBind(ClientContext &context, ScalarFunction &bound_function,
@@ -121268,6 +121279,10 @@ unique_ptr<NodeStatistics> StatisticsPropagator::PropagateStatistics(LogicalCros
121268
121279
 
121269
121280
  namespace duckdb {
121270
121281
 
121282
+ static bool IsCompareDistinct(ExpressionType type) {
121283
+ return type == ExpressionType::COMPARE_DISTINCT_FROM || type == ExpressionType::COMPARE_NOT_DISTINCT_FROM;
121284
+ }
121285
+
121271
121286
  bool StatisticsPropagator::ExpressionIsConstant(Expression &expr, const Value &val) {
121272
121287
  if (expr.GetExpressionClass() != ExpressionClass::BOUND_CONSTANT) {
121273
121288
  return false;
@@ -121295,8 +121310,10 @@ void StatisticsPropagator::SetStatisticsNotNull(ColumnBinding binding) {
121295
121310
 
121296
121311
  void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &stats, ExpressionType comparison_type,
121297
121312
  const Value &constant) {
121298
- // any comparison filter removes all null values
121299
- stats.validity_stats = make_unique<ValidityStatistics>(false);
121313
+ // regular comparisons removes all null values
121314
+ if (!IsCompareDistinct(comparison_type)) {
121315
+ stats.validity_stats = make_unique<ValidityStatistics>(false);
121316
+ }
121300
121317
  if (!stats.type.IsNumeric()) {
121301
121318
  // don't handle non-numeric columns here (yet)
121302
121319
  return;
@@ -121332,9 +121349,11 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &stats, Express
121332
121349
 
121333
121350
  void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseStatistics &rstats,
121334
121351
  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);
121352
+ // regular comparisons removes all null values
121353
+ if (!IsCompareDistinct(comparison_type)) {
121354
+ lstats.validity_stats = make_unique<ValidityStatistics>(false);
121355
+ rstats.validity_stats = make_unique<ValidityStatistics>(false);
121356
+ }
121338
121357
  D_ASSERT(lstats.type == rstats.type);
121339
121358
  if (!lstats.type.IsNumeric()) {
121340
121359
  // don't handle non-numeric columns here (yet)
@@ -121380,6 +121399,7 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseSt
121380
121399
  }
121381
121400
  break;
121382
121401
  case ExpressionType::COMPARE_EQUAL:
121402
+ case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
121383
121403
  // LEFT = RIGHT
121384
121404
  // only the tightest bounds pass
121385
121405
  // so if we have e.g. left = [-50, 250] and right = [-100, 100]
@@ -121405,10 +121425,11 @@ void StatisticsPropagator::UpdateFilterStatistics(BaseStatistics &lstats, BaseSt
121405
121425
  void StatisticsPropagator::UpdateFilterStatistics(Expression &left, Expression &right, ExpressionType comparison_type) {
121406
121426
  // first check if either side is a bound column ref
121407
121427
  // any column ref involved in a comparison will not be null after the comparison
121408
- if (left.type == ExpressionType::BOUND_COLUMN_REF) {
121428
+ bool compare_distinct = IsCompareDistinct(comparison_type);
121429
+ if (!compare_distinct && left.type == ExpressionType::BOUND_COLUMN_REF) {
121409
121430
  SetStatisticsNotNull(((BoundColumnRefExpression &)left).binding);
121410
121431
  }
121411
- if (right.type == ExpressionType::BOUND_COLUMN_REF) {
121432
+ if (!compare_distinct && right.type == ExpressionType::BOUND_COLUMN_REF) {
121412
121433
  SetStatisticsNotNull(((BoundColumnRefExpression &)right).binding);
121413
121434
  }
121414
121435
  // check if this is a comparison between a constant and a column ref
@@ -153545,8 +153566,9 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153545
153566
  join->children.push_back(move(plan->children[1]));
153546
153567
  return move(join);
153547
153568
  }
153569
+ case LogicalOperatorType::LOGICAL_ANY_JOIN:
153548
153570
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN: {
153549
- auto &join = (LogicalComparisonJoin &)*plan;
153571
+ auto &join = (LogicalJoin &)*plan;
153550
153572
  D_ASSERT(plan->children.size() == 2);
153551
153573
  // check the correlated expressions in the children of the join
153552
153574
  bool left_has_correlation = has_correlated_expressions.find(plan->children[0].get())->second;
@@ -153571,6 +153593,13 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153571
153593
  plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
153572
153594
  return plan;
153573
153595
  }
153596
+ } else if (join.join_type == JoinType::RIGHT) {
153597
+ // left outer join
153598
+ if (!left_has_correlation) {
153599
+ // only right has correlation: push into right
153600
+ plan->children[1] = PushDownDependentJoinInternal(move(plan->children[1]));
153601
+ return plan;
153602
+ }
153574
153603
  } else if (join.join_type == JoinType::MARK) {
153575
153604
  if (right_has_correlation) {
153576
153605
  throw Exception("MARK join with correlation in RHS not supported");
@@ -153586,27 +153615,42 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
153586
153615
  }
153587
153616
  // both sides have correlation
153588
153617
  // 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
153618
  plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
153593
153619
  auto left_binding = this->base_binding;
153594
153620
  plan->children[1] = PushDownDependentJoinInternal(move(plan->children[1]));
153595
153621
  auto right_binding = this->base_binding;
153622
+ // NOTE: for OUTER JOINS it matters what the BASE BINDING is after the join
153623
+ // for the LEFT OUTER JOIN, we want the LEFT side to be the base binding after we push
153624
+ // because the RIGHT binding might contain NULL values
153596
153625
  if (join.join_type == JoinType::LEFT) {
153597
153626
  this->base_binding = left_binding;
153627
+ } else if (join.join_type == JoinType::RIGHT) {
153628
+ this->base_binding = right_binding;
153598
153629
  }
153599
153630
  // add the correlated columns to the join conditions
153600
153631
  for (idx_t i = 0; i < correlated_columns.size(); i++) {
153601
- JoinCondition cond;
153602
-
153603
- cond.left = make_unique<BoundColumnRefExpression>(
153632
+ auto left = make_unique<BoundColumnRefExpression>(
153604
153633
  correlated_columns[i].type, ColumnBinding(left_binding.table_index, left_binding.column_index + i));
153605
- cond.right = make_unique<BoundColumnRefExpression>(
153634
+ auto right = make_unique<BoundColumnRefExpression>(
153606
153635
  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));
153636
+
153637
+ if (join.type == LogicalOperatorType::LOGICAL_COMPARISON_JOIN) {
153638
+ JoinCondition cond;
153639
+ cond.left = move(left);
153640
+ cond.right = move(right);
153641
+ cond.comparison = ExpressionType::COMPARE_EQUAL;
153642
+ cond.null_values_are_equal = true;
153643
+
153644
+ auto &comparison_join = (LogicalComparisonJoin &)join;
153645
+ comparison_join.conditions.push_back(move(cond));
153646
+ } else {
153647
+ auto &any_join = (LogicalAnyJoin &)join;
153648
+ auto comparison = make_unique<BoundComparisonExpression>(ExpressionType::COMPARE_NOT_DISTINCT_FROM,
153649
+ move(left), move(right));
153650
+ auto conjunction = make_unique<BoundConjunctionExpression>(ExpressionType::CONJUNCTION_AND,
153651
+ move(comparison), move(any_join.condition));
153652
+ any_join.condition = move(conjunction);
153653
+ }
153610
153654
  }
153611
153655
  // then we replace any correlated expressions with the corresponding entry in the correlated_map
153612
153656
  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 "9a485b0fd"
15
+ #define DUCKDB_VERSION "v0.3.2-dev1316"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //