duckdb 0.4.1-dev2376.0 → 0.4.1-dev2385.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.4.1-dev2376.0",
4
+ "version": "0.4.1-dev2385.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -9279,6 +9279,12 @@ string StatementReturnTypeToString(StatementReturnType type) {
9279
9279
 
9280
9280
 
9281
9281
 
9282
+ #ifdef DUCKDB_CRASH_ON_ASSERT
9283
+
9284
+ #include <stdio.h>
9285
+ #include <stdlib.h>
9286
+ #endif
9287
+
9282
9288
  namespace duckdb {
9283
9289
 
9284
9290
  Exception::Exception(const string &msg) : std::exception(), type(ExceptionType::INVALID), raw_message_(msg) {
@@ -9561,6 +9567,10 @@ FatalException::FatalException(ExceptionType type, const string &msg) : Exceptio
9561
9567
  }
9562
9568
 
9563
9569
  InternalException::InternalException(const string &msg) : FatalException(ExceptionType::INTERNAL, msg) {
9570
+ #ifdef DUCKDB_CRASH_ON_ASSERT
9571
+ Printer::Print("ABORT THROWN BY INTERNAL EXCEPTION: " + msg);
9572
+ abort();
9573
+ #endif
9564
9574
  }
9565
9575
 
9566
9576
  InvalidInputException::InvalidInputException(const string &msg) : Exception(ExceptionType::INVALID_INPUT, msg) {
@@ -27686,9 +27696,8 @@ void PreservedError::Throw(const string &prepended_message) const {
27686
27696
  if (!prepended_message.empty()) {
27687
27697
  string new_message = prepended_message + raw_message;
27688
27698
  Exception::ThrowAsTypeWithMessage(type, new_message);
27689
- } else {
27690
- Exception::ThrowAsTypeWithMessage(type, raw_message);
27691
27699
  }
27700
+ Exception::ThrowAsTypeWithMessage(type, raw_message);
27692
27701
  }
27693
27702
 
27694
27703
  const ExceptionType &PreservedError::Type() const {
@@ -42514,6 +42523,15 @@ void DataChunk::SetValue(idx_t col_idx, idx_t index, const Value &val) {
42514
42523
  data[col_idx].SetValue(index, val);
42515
42524
  }
42516
42525
 
42526
+ bool DataChunk::AllConstant() const {
42527
+ for (auto &v : data) {
42528
+ if (v.GetVectorType() != VectorType::CONSTANT_VECTOR) {
42529
+ return false;
42530
+ }
42531
+ }
42532
+ return true;
42533
+ }
42534
+
42517
42535
  void DataChunk::Reference(DataChunk &chunk) {
42518
42536
  D_ASSERT(chunk.ColumnCount() <= ColumnCount());
42519
42537
  SetCardinality(chunk);
@@ -55061,7 +55079,7 @@ static bool ListCastSwitch(Vector &source, Vector &result, idx_t count, string *
55061
55079
  case LogicalTypeId::LIST: {
55062
55080
  // only handle constant and flat vectors here for now
55063
55081
  if (source.GetVectorType() == VectorType::CONSTANT_VECTOR) {
55064
- result.SetVectorType(source.GetVectorType());
55082
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
55065
55083
  ConstantVector::SetNull(result, ConstantVector::IsNull(source));
55066
55084
 
55067
55085
  auto ldata = ConstantVector::GetData<list_entry_t>(source);
@@ -58739,6 +58757,8 @@ bool ExpressionExecutor::TryEvaluateScalar(const Expression &expr, Value &result
58739
58757
  try {
58740
58758
  result = EvaluateScalar(expr);
58741
58759
  return true;
58760
+ } catch (InternalException &ex) {
58761
+ throw ex;
58742
58762
  } catch (...) {
58743
58763
  return false;
58744
58764
  }
@@ -84149,6 +84169,13 @@ protected:
84149
84169
  void ResolveTypes() override {
84150
84170
  types.emplace_back(LogicalType::BOOLEAN);
84151
84171
  }
84172
+
84173
+ bool RequireOptimizer() const override {
84174
+ if (!prepared->properties.bound_all_parameters) {
84175
+ return false;
84176
+ }
84177
+ return children[0]->RequireOptimizer();
84178
+ }
84152
84179
  };
84153
84180
  } // namespace duckdb
84154
84181
 
@@ -93182,8 +93209,8 @@ unique_ptr<FunctionData> HistogramBindFunction(ClientContext &context, Aggregate
93182
93209
 
93183
93210
  D_ASSERT(arguments.size() == 1);
93184
93211
  child_list_t<LogicalType> struct_children;
93185
- struct_children.push_back({"bucket", LogicalType::LIST(arguments[0]->return_type)});
93186
- struct_children.push_back({"count", LogicalType::LIST(LogicalType::UBIGINT)});
93212
+ struct_children.push_back({"key", LogicalType::LIST(arguments[0]->return_type)});
93213
+ struct_children.push_back({"value", LogicalType::LIST(LogicalType::UBIGINT)});
93187
93214
  auto struct_type = LogicalType::MAP(move(struct_children));
93188
93215
 
93189
93216
  function.return_type = struct_type;
@@ -102470,10 +102497,13 @@ static void ArraySliceFunction(DataChunk &args, ExpressionState &state, Vector &
102470
102497
  Vector &b = args.data[1];
102471
102498
  Vector &e = args.data[2];
102472
102499
 
102473
- s.Flatten(count);
102500
+ result.SetVectorType(args.AllConstant() ? VectorType::CONSTANT_VECTOR : VectorType::FLAT_VECTOR);
102474
102501
  switch (result.GetType().id()) {
102475
102502
  case LogicalTypeId::LIST:
102476
102503
  // Share the value dictionary as we are just going to slice it
102504
+ if (s.GetVectorType() != VectorType::FLAT_VECTOR && s.GetVectorType() != VectorType::CONSTANT_VECTOR) {
102505
+ s.Flatten(count);
102506
+ }
102477
102507
  ListVector::ReferenceEntry(result, s);
102478
102508
  ExecuteSlice<list_entry_t, int64_t>(result, s, b, e, count);
102479
102509
  break;
@@ -102483,14 +102513,6 @@ static void ArraySliceFunction(DataChunk &args, ExpressionState &state, Vector &
102483
102513
  default:
102484
102514
  throw NotImplementedException("Specifier type not implemented");
102485
102515
  }
102486
-
102487
- result.SetVectorType(VectorType::CONSTANT_VECTOR);
102488
- for (idx_t i = 0; i < args.ColumnCount(); i++) {
102489
- if (args.data[i].GetVectorType() != VectorType::CONSTANT_VECTOR) {
102490
- result.SetVectorType(VectorType::FLAT_VECTOR);
102491
- break;
102492
- }
102493
- }
102494
102516
  }
102495
102517
 
102496
102518
  static unique_ptr<FunctionData> ArraySliceBind(ClientContext &context, ScalarFunction &bound_function,
@@ -102625,6 +102647,10 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
102625
102647
  }
102626
102648
  }
102627
102649
  }
102650
+
102651
+ if (args.AllConstant()) {
102652
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
102653
+ }
102628
102654
  }
102629
102655
 
102630
102656
  template <class T, class OP>
@@ -102824,6 +102850,9 @@ void ListFlattenFunction(DataChunk &args, ExpressionState &state, Vector &result
102824
102850
  result_entries[i].offset = 0;
102825
102851
  result_entries[i].length = 0;
102826
102852
  }
102853
+ if (args.AllConstant()) {
102854
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
102855
+ }
102827
102856
  return;
102828
102857
  }
102829
102858
 
@@ -102869,7 +102898,7 @@ void ListFlattenFunction(DataChunk &args, ExpressionState &state, Vector &result
102869
102898
  offset += length;
102870
102899
  }
102871
102900
 
102872
- if (input.GetVectorType() == VectorType::CONSTANT_VECTOR) {
102901
+ if (args.AllConstant()) {
102873
102902
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
102874
102903
  }
102875
102904
  }
@@ -103223,6 +103252,10 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
103223
103252
  throw InternalException("Unimplemented histogram aggregate");
103224
103253
  }
103225
103254
  }
103255
+
103256
+ if (args.AllConstant()) {
103257
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
103258
+ }
103226
103259
  }
103227
103260
 
103228
103261
  static void ListAggregateFunction(DataChunk &args, ExpressionState &state, Vector &result) {
@@ -104069,6 +104102,10 @@ static void ListLambdaFunction(DataChunk &args, ExpressionState &state, Vector &
104069
104102
  AppendFilteredToResult(lambda_vector, result_entries, elem_cnt, result, curr_list_len, curr_list_offset,
104070
104103
  appended_lists_cnt, lists_len, curr_original_list_len, input_chunk);
104071
104104
  }
104105
+
104106
+ if (args.AllConstant()) {
104107
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
104108
+ }
104072
104109
  }
104073
104110
 
104074
104111
  static void ListTransformFunction(DataChunk &args, ExpressionState &state, Vector &result) {
@@ -104272,7 +104309,12 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
104272
104309
  result.SetVectorType(VectorType::FLAT_VECTOR);
104273
104310
  auto &result_validity = FlatVector::Validity(result);
104274
104311
 
104275
- args.Flatten();
104312
+ for (auto &v : args.data) {
104313
+ if (v.GetVectorType() != VectorType::FLAT_VECTOR && v.GetVectorType() != VectorType::CONSTANT_VECTOR) {
104314
+ v.Flatten(count);
104315
+ }
104316
+ }
104317
+
104276
104318
  if (lists.GetType().id() == LogicalTypeId::SQLNULL) {
104277
104319
  result_validity.SetInvalid(0);
104278
104320
  return;
@@ -104394,6 +104436,10 @@ static void ListSortFunction(DataChunk &args, ExpressionState &state, Vector &re
104394
104436
  }
104395
104437
 
104396
104438
  result.Reference(lists);
104439
+
104440
+ if (args.AllConstant()) {
104441
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
104442
+ }
104397
104443
  }
104398
104444
 
104399
104445
  static unique_ptr<FunctionData> ListSortBind(ClientContext &context, ScalarFunction &bound_function,
@@ -105326,6 +105372,10 @@ static void MapFromEntriesFunction(DataChunk &args, ExpressionState &state, Vect
105326
105372
  }
105327
105373
  MapConversionVerify(result, count);
105328
105374
  result.Verify(count);
105375
+
105376
+ if (args.AllConstant()) {
105377
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
105378
+ }
105329
105379
  }
105330
105380
 
105331
105381
  static unique_ptr<FunctionData> MapFromEntriesBind(ClientContext &context, ScalarFunction &bound_function,
@@ -113288,8 +113338,7 @@ static void StringSplitExecutor(DataChunk &args, ExpressionState &state, Vector
113288
113338
  }
113289
113339
 
113290
113340
  D_ASSERT(ListVector::GetListSize(result) == total_len);
113291
- if (args.data[0].GetVectorType() == VectorType::CONSTANT_VECTOR &&
113292
- args.data[1].GetVectorType() == VectorType::CONSTANT_VECTOR) {
113341
+ if (args.AllConstant()) {
113293
113342
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
113294
113343
  }
113295
113344
  }
@@ -113986,7 +114035,6 @@ static void StructInsertFunction(DataChunk &args, ExpressionState &state, Vector
113986
114035
  starting_vec.Verify(args.size());
113987
114036
 
113988
114037
  auto &starting_child_entries = StructVector::GetEntries(starting_vec);
113989
-
113990
114038
  auto &result_child_entries = StructVector::GetEntries(result);
113991
114039
 
113992
114040
  // Assign the starting vector entries to the result vector
@@ -114001,6 +114049,10 @@ static void StructInsertFunction(DataChunk &args, ExpressionState &state, Vector
114001
114049
  }
114002
114050
 
114003
114051
  result.Verify(args.size());
114052
+
114053
+ if (args.AllConstant()) {
114054
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
114055
+ }
114004
114056
  }
114005
114057
 
114006
114058
  static unique_ptr<FunctionData> StructInsertBind(ClientContext &context, ScalarFunction &bound_function,
@@ -126073,7 +126125,7 @@ shared_ptr<PreparedStatementData> ClientContext::CreatePreparedStatement(ClientC
126073
126125
  #ifdef DEBUG
126074
126126
  plan->Verify(*this);
126075
126127
  #endif
126076
- if (config.enable_optimizer) {
126128
+ if (config.enable_optimizer && plan->RequireOptimizer()) {
126077
126129
  profiler.StartPhase("optimizer");
126078
126130
  Optimizer optimizer(*planner.binder, *this);
126079
126131
  plan = optimizer.Optimize(move(plan));
@@ -137468,8 +137520,11 @@ PendingQueryResult::~PendingQueryResult() {
137468
137520
 
137469
137521
  unique_ptr<ClientContextLock> PendingQueryResult::LockContext() {
137470
137522
  if (!context) {
137471
- throw InvalidInputException("Attempting to execute an unsuccessful or closed pending query result\nError: %s",
137472
- GetError());
137523
+ if (HasError()) {
137524
+ throw InvalidInputException(
137525
+ "Attempting to execute an unsuccessful or closed pending query result\nError: %s", GetError());
137526
+ }
137527
+ throw InvalidInputException("Attempting to execute an unsuccessful or closed pending query result");
137473
137528
  }
137474
137529
  return context->LockContext();
137475
137530
  }
@@ -137480,8 +137535,11 @@ void PendingQueryResult::CheckExecutableInternal(ClientContextLock &lock) {
137480
137535
  invalidated = !context->IsActiveResult(lock, this);
137481
137536
  }
137482
137537
  if (invalidated) {
137483
- throw InvalidInputException("Attempting to execute an unsuccessful or closed pending query result\nError: %s",
137484
- GetError());
137538
+ if (HasError()) {
137539
+ throw InvalidInputException(
137540
+ "Attempting to execute an unsuccessful or closed pending query result\nError: %s", GetError());
137541
+ }
137542
+ throw InvalidInputException("Attempting to execute an unsuccessful or closed pending query result");
137485
137543
  }
137486
137544
  }
137487
137545
 
@@ -166718,12 +166776,12 @@ vector<OrderByNode> Parser::ParseOrderList(const string &select_list, ParserOpti
166718
166776
  }
166719
166777
  auto &select = (SelectStatement &)*parser.statements[0];
166720
166778
  if (select.node->type != QueryNodeType::SELECT_NODE) {
166721
- throw InternalException("Expected a single SELECT node");
166779
+ throw ParserException("Expected a single SELECT node");
166722
166780
  }
166723
166781
  auto &select_node = (SelectNode &)*select.node;
166724
166782
  if (select_node.modifiers.empty() || select_node.modifiers[0]->type != ResultModifierType::ORDER_MODIFIER ||
166725
166783
  select_node.modifiers.size() != 1) {
166726
- throw InternalException("Expected a single ORDER clause");
166784
+ throw ParserException("Expected a single ORDER clause");
166727
166785
  }
166728
166786
  auto &order = (OrderModifier &)*select_node.modifiers[0];
166729
166787
  return move(order.orders);
@@ -166761,7 +166819,7 @@ vector<vector<unique_ptr<ParsedExpression>>> Parser::ParseValuesList(const strin
166761
166819
  }
166762
166820
  auto &select_node = (SelectNode &)*select.node;
166763
166821
  if (!select_node.from_table || select_node.from_table->type != TableReferenceType::EXPRESSION_LIST) {
166764
- throw InternalException("Expected a single VALUES statement");
166822
+ throw ParserException("Expected a single VALUES statement");
166765
166823
  }
166766
166824
  auto &values_list = (ExpressionListRef &)*select_node.from_table;
166767
166825
  return move(values_list.values);
@@ -208006,7 +208064,7 @@ bool PreparedStatementVerifier::Run(
208006
208064
  }
208007
208065
  auto execute_result = run(string(), move(execute_statement));
208008
208066
  if (execute_result->HasError()) {
208009
- prepare_result->ThrowError("Failed execute during verify: ");
208067
+ execute_result->ThrowError("Failed execute during verify: ");
208010
208068
  }
208011
208069
  materialized_result = unique_ptr_cast<QueryResult, MaterializedQueryResult>(move(execute_result));
208012
208070
  } catch (const Exception &ex) {
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 "32c0d9c35"
15
- #define DUCKDB_VERSION "v0.4.1-dev2376"
14
+ #define DUCKDB_SOURCE_ID "94920472d"
15
+ #define DUCKDB_VERSION "v0.4.1-dev2385"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -4608,6 +4608,9 @@ public:
4608
4608
  DUCKDB_API Value GetValue(idx_t col_idx, idx_t index) const;
4609
4609
  DUCKDB_API void SetValue(idx_t col_idx, idx_t index, const Value &val);
4610
4610
 
4611
+ //! Returns true if all vectors in the DataChunk are constant
4612
+ DUCKDB_API bool AllConstant() const;
4613
+
4611
4614
  //! Set the DataChunk to reference another data chunk
4612
4615
  DUCKDB_API void Reference(DataChunk &chunk);
4613
4616
  //! Set the DataChunk to own the data of data chunk, destroying the other chunk in the process
@@ -9971,6 +9974,10 @@ public:
9971
9974
 
9972
9975
  static unique_ptr<LogicalOperator> Deserialize(Deserializer &deserializer, PlanDeserializationState &state);
9973
9976
 
9977
+ virtual bool RequireOptimizer() const {
9978
+ return true;
9979
+ }
9980
+
9974
9981
  protected:
9975
9982
  //! Resolve types for this specific operator
9976
9983
  virtual void ResolveTypes() = 0;