duckdb 0.3.5-dev582.0 → 0.3.5-dev591.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.5-dev582.0",
4
+ "version": "0.3.5-dev591.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -114193,6 +114193,15 @@ struct DebugForceExternal {
114193
114193
  static Value GetSetting(ClientContext &context);
114194
114194
  };
114195
114195
 
114196
+ struct DebugForceNoCrossProduct {
114197
+ static constexpr const char *Name = "debug_force_no_cross_product";
114198
+ static constexpr const char *Description =
114199
+ "DEBUG SETTING: Force disable cross product generation when hyper graph isn't connected, used for testing";
114200
+ static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
114201
+ static void SetLocal(ClientContext &context, const Value &parameter);
114202
+ static Value GetSetting(ClientContext &context);
114203
+ };
114204
+
114196
114205
  struct DebugManyFreeListBlocks {
114197
114206
  static constexpr const char *Name = "debug_many_free_list_blocks";
114198
114207
  static constexpr const char *Description = "DEBUG SETTING: add additional blocks to the free list";
@@ -114440,6 +114449,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
114440
114449
  DUCKDB_GLOBAL(CheckpointThresholdSetting),
114441
114450
  DUCKDB_GLOBAL(DebugCheckpointAbort),
114442
114451
  DUCKDB_LOCAL(DebugForceExternal),
114452
+ DUCKDB_LOCAL(DebugForceNoCrossProduct),
114443
114453
  DUCKDB_GLOBAL(DebugManyFreeListBlocks),
114444
114454
  DUCKDB_GLOBAL(DebugWindowMode),
114445
114455
  DUCKDB_GLOBAL_LOCAL(DefaultCollationSetting),
@@ -127680,6 +127690,7 @@ vector<shared_ptr<ExternalDependency>> Relation::GetAllDependencies() {
127680
127690
 
127681
127691
 
127682
127692
 
127693
+
127683
127694
  namespace duckdb {
127684
127695
 
127685
127696
  //===--------------------------------------------------------------------===//
@@ -127760,6 +127771,17 @@ Value DebugForceExternal::GetSetting(ClientContext &context) {
127760
127771
  return Value::BOOLEAN(ClientConfig::GetConfig(context).force_external);
127761
127772
  }
127762
127773
 
127774
+ //===--------------------------------------------------------------------===//
127775
+ // Debug Force NoCrossProduct
127776
+ //===--------------------------------------------------------------------===//
127777
+ void DebugForceNoCrossProduct::SetLocal(ClientContext &context, const Value &input) {
127778
+ ClientConfig::GetConfig(context).force_no_cross_product = input.GetValue<bool>();
127779
+ }
127780
+
127781
+ Value DebugForceNoCrossProduct::GetSetting(ClientContext &context) {
127782
+ return Value::BOOLEAN(ClientConfig::GetConfig(context).force_no_cross_product);
127783
+ }
127784
+
127763
127785
  //===--------------------------------------------------------------------===//
127764
127786
  // Debug Many Free List blocks
127765
127787
  //===--------------------------------------------------------------------===//
@@ -131867,6 +131889,7 @@ private:
131867
131889
 
131868
131890
 
131869
131891
 
131892
+
131870
131893
 
131871
131894
 
131872
131895
  #include <algorithm>
@@ -132110,6 +132133,9 @@ bool JoinOrderOptimizer::TryEmitPair(JoinRelationSet *left, JoinRelationSet *rig
132110
132133
  }
132111
132134
 
132112
132135
  bool JoinOrderOptimizer::EmitCSG(JoinRelationSet *node) {
132136
+ if (node->count == relations.size()) {
132137
+ return true;
132138
+ }
132113
132139
  // create the exclusion set as everything inside the subgraph AND anything with members BELOW it
132114
132140
  unordered_set<idx_t> exclusion_set;
132115
132141
  for (idx_t i = 0; i < node->relations[0]; i++) {
@@ -132153,7 +132179,7 @@ bool JoinOrderOptimizer::EnumerateCmpRecursive(JoinRelationSet *left, JoinRelati
132153
132179
  auto neighbor = set_manager.GetJoinRelation(neighbors[i]);
132154
132180
  // emit the combinations of this node and its neighbors
132155
132181
  auto combined_set = set_manager.Union(right, neighbor);
132156
- if (plans.find(combined_set) != plans.end()) {
132182
+ if (combined_set->count > right->count && plans.find(combined_set) != plans.end()) {
132157
132183
  auto connection = query_graph.GetConnection(left, combined_set);
132158
132184
  if (connection) {
132159
132185
  if (!TryEmitPair(left, combined_set, connection)) {
@@ -132164,9 +132190,9 @@ bool JoinOrderOptimizer::EnumerateCmpRecursive(JoinRelationSet *left, JoinRelati
132164
132190
  union_sets[i] = combined_set;
132165
132191
  }
132166
132192
  // recursively enumerate the sets
132193
+ unordered_set<idx_t> new_exclusion_set = exclusion_set;
132167
132194
  for (idx_t i = 0; i < neighbors.size(); i++) {
132168
132195
  // updated the set of excluded entries with this neighbor
132169
- unordered_set<idx_t> new_exclusion_set = exclusion_set;
132170
132196
  new_exclusion_set.insert(neighbors[i]);
132171
132197
  if (!EnumerateCmpRecursive(left, union_sets[i], new_exclusion_set)) {
132172
132198
  return false;
@@ -132188,7 +132214,7 @@ bool JoinOrderOptimizer::EnumerateCSGRecursive(JoinRelationSet *node, unordered_
132188
132214
  auto neighbor = set_manager.GetJoinRelation(neighbors[i]);
132189
132215
  // emit the combinations of this node and its neighbors
132190
132216
  auto new_set = set_manager.Union(node, neighbor);
132191
- if (plans.find(new_set) != plans.end()) {
132217
+ if (new_set->count > node->count && plans.find(new_set) != plans.end()) {
132192
132218
  if (!EmitCSG(new_set)) {
132193
132219
  return false;
132194
132220
  }
@@ -132196,9 +132222,9 @@ bool JoinOrderOptimizer::EnumerateCSGRecursive(JoinRelationSet *node, unordered_
132196
132222
  union_sets[i] = new_set;
132197
132223
  }
132198
132224
  // recursively enumerate the sets
132225
+ unordered_set<idx_t> new_exclusion_set = exclusion_set;
132199
132226
  for (idx_t i = 0; i < neighbors.size(); i++) {
132200
132227
  // updated the set of excluded entries with this neighbor
132201
- unordered_set<idx_t> new_exclusion_set = exclusion_set;
132202
132228
  new_exclusion_set.insert(neighbors[i]);
132203
132229
  if (!EnumerateCSGRecursive(union_sets[i], new_exclusion_set)) {
132204
132230
  return false;
@@ -132632,6 +132658,9 @@ unique_ptr<LogicalOperator> JoinOrderOptimizer::Optimize(unique_ptr<LogicalOpera
132632
132658
  // could not find the final plan
132633
132659
  // this should only happen in case the sets are actually disjunct
132634
132660
  // in this case we need to generate cross product to connect the disjoint sets
132661
+ if (context.config.force_no_cross_product) {
132662
+ throw InternalException("HyperGraph isn't connected");
132663
+ }
132635
132664
  GenerateCrossProducts();
132636
132665
  //! solve the join order again
132637
132666
  SolveJoinOrder();
@@ -159826,8 +159855,10 @@ BindResult ExpressionBinder::BindExpression(ComparisonExpression &expr, idx_t de
159826
159855
  // now obtain the result type of the input types
159827
159856
  auto input_type = BoundComparisonExpression::BindComparison(left_sql_type, right_sql_type);
159828
159857
  // add casts (if necessary)
159829
- left.expr = BoundCastExpression::AddCastToType(move(left.expr), input_type);
159830
- right.expr = BoundCastExpression::AddCastToType(move(right.expr), input_type);
159858
+ left.expr = BoundCastExpression::AddCastToType(move(left.expr), input_type, input_type.id() == LogicalTypeId::ENUM);
159859
+ right.expr =
159860
+ BoundCastExpression::AddCastToType(move(right.expr), input_type, input_type.id() == LogicalTypeId::ENUM);
159861
+
159831
159862
  if (input_type.id() == LogicalTypeId::VARCHAR) {
159832
159863
  // handle collation
159833
159864
  auto collation = StringType::GetCollation(input_type);
@@ -166426,7 +166457,8 @@ BoundCastExpression::BoundCastExpression(unique_ptr<Expression> child_p, Logical
166426
166457
  try_cast(try_cast_p) {
166427
166458
  }
166428
166459
 
166429
- unique_ptr<Expression> BoundCastExpression::AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type) {
166460
+ unique_ptr<Expression> BoundCastExpression::AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type,
166461
+ bool try_cast) {
166430
166462
  D_ASSERT(expr);
166431
166463
  if (expr->expression_class == ExpressionClass::BOUND_PARAMETER) {
166432
166464
  auto &parameter = (BoundParameterExpression &)*expr;
@@ -166443,7 +166475,7 @@ unique_ptr<Expression> BoundCastExpression::AddCastToType(unique_ptr<Expression>
166443
166475
  return expr;
166444
166476
  }
166445
166477
  }
166446
- return make_unique<BoundCastExpression>(move(expr), target_type);
166478
+ return make_unique<BoundCastExpression>(move(expr), target_type, try_cast);
166447
166479
  }
166448
166480
  return expr;
166449
166481
  }
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 "6dcb417dd"
15
- #define DUCKDB_VERSION "v0.3.5-dev582"
14
+ #define DUCKDB_SOURCE_ID "b0155fd5b"
15
+ #define DUCKDB_VERSION "v0.3.5-dev591"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -12411,7 +12411,8 @@ public:
12411
12411
  }
12412
12412
 
12413
12413
  //! Cast an expression to the specified SQL type if required
12414
- static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type);
12414
+ static unique_ptr<Expression> AddCastToType(unique_ptr<Expression> expr, const LogicalType &target_type,
12415
+ bool try_cast = false);
12415
12416
  //! Returns true if a cast is invertible (i.e. CAST(s -> t -> s) = s for all values of s). This is not true for e.g.
12416
12417
  //! boolean casts, because that can be e.g. -1 -> TRUE -> 1. This is necessary to prevent some optimizer bugs.
12417
12418
  static bool CastIsInvertible(const LogicalType &source_type, const LogicalType &target_type);
@@ -17327,6 +17328,8 @@ struct ClientConfig {
17327
17328
  bool force_index_join = false;
17328
17329
  //! Force out-of-core computation for operators that support it, used for testing
17329
17330
  bool force_external = false;
17331
+ //! Force disable cross product generation when hyper graph isn't connected, used for testing
17332
+ bool force_no_cross_product = false;
17330
17333
  //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
17331
17334
  //! elements)
17332
17335
  idx_t perfect_ht_threshold = 12;