duckdb 0.5.1-dev207.0 → 0.5.1-dev216.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-dev207.0",
4
+ "version": "0.5.1-dev216.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -16841,9 +16841,15 @@ string FileSystem::ConvertSeparators(const string &path) {
16841
16841
  }
16842
16842
 
16843
16843
  string FileSystem::ExtractBaseName(const string &path) {
16844
+ if (path.empty()) {
16845
+ return string();
16846
+ }
16844
16847
  auto normalized_path = ConvertSeparators(path);
16845
16848
  auto sep = PathSeparator();
16846
- auto vec = StringUtil::Split(StringUtil::Split(normalized_path, sep).back(), ".");
16849
+ auto splits = StringUtil::Split(normalized_path, sep);
16850
+ D_ASSERT(!splits.empty());
16851
+ auto vec = StringUtil::Split(splits.back(), ".");
16852
+ D_ASSERT(!vec.empty());
16847
16853
  return vec[0];
16848
16854
  }
16849
16855
 
@@ -91143,7 +91149,21 @@ struct ModeIncluded {
91143
91149
  const idx_t bias;
91144
91150
  };
91145
91151
 
91146
- template <typename KEY_TYPE>
91152
+ struct ModeAssignmentStandard {
91153
+ template <class INPUT_TYPE, class RESULT_TYPE>
91154
+ static RESULT_TYPE Assign(Vector &result, INPUT_TYPE input) {
91155
+ return RESULT_TYPE(input);
91156
+ }
91157
+ };
91158
+
91159
+ struct ModeAssignmentString {
91160
+ template <class INPUT_TYPE, class RESULT_TYPE>
91161
+ static RESULT_TYPE Assign(Vector &result, INPUT_TYPE input) {
91162
+ return StringVector::AddString(result, input);
91163
+ }
91164
+ };
91165
+
91166
+ template <typename KEY_TYPE, typename ASSIGN_OP>
91147
91167
  struct ModeFunction {
91148
91168
  template <class STATE>
91149
91169
  static void Initialize(STATE *state) {
@@ -91256,7 +91276,7 @@ struct ModeFunction {
91256
91276
  }
91257
91277
 
91258
91278
  if (state->valid) {
91259
- rdata[rid] = RESULT_TYPE(*state->mode);
91279
+ rdata[rid] = ASSIGN_OP::template Assign<INPUT_TYPE, RESULT_TYPE>(result, *state->mode);
91260
91280
  } else {
91261
91281
  rmask.Set(rid, false);
91262
91282
  }
@@ -91272,10 +91292,10 @@ struct ModeFunction {
91272
91292
  }
91273
91293
  };
91274
91294
 
91275
- template <typename INPUT_TYPE, typename KEY_TYPE>
91295
+ template <typename INPUT_TYPE, typename KEY_TYPE, typename ASSIGN_OP = ModeAssignmentStandard>
91276
91296
  AggregateFunction GetTypedModeFunction(const LogicalType &type) {
91277
91297
  using STATE = ModeState<KEY_TYPE>;
91278
- using OP = ModeFunction<KEY_TYPE>;
91298
+ using OP = ModeFunction<KEY_TYPE, ASSIGN_OP>;
91279
91299
  auto func = AggregateFunction::UnaryAggregateDestructor<STATE, INPUT_TYPE, INPUT_TYPE, OP>(type, type);
91280
91300
  func.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, INPUT_TYPE, OP>;
91281
91301
  return func;
@@ -91311,7 +91331,7 @@ AggregateFunction GetModeAggregate(const LogicalType &type) {
91311
91331
  return GetTypedModeFunction<interval_t, interval_t>(type);
91312
91332
 
91313
91333
  case PhysicalType::VARCHAR:
91314
- return GetTypedModeFunction<string_t, string>(type);
91334
+ return GetTypedModeFunction<string_t, string, ModeAssignmentString>(type);
91315
91335
 
91316
91336
  default:
91317
91337
  throw NotImplementedException("Unimplemented mode aggregate");
@@ -108380,6 +108400,24 @@ interval_t DivideOperator::Operation(interval_t left, int64_t right) {
108380
108400
  return left;
108381
108401
  }
108382
108402
 
108403
+ struct BinaryNumericDivideWrapper {
108404
+ template <class FUNC, class OP, class LEFT_TYPE, class RIGHT_TYPE, class RESULT_TYPE>
108405
+ static inline RESULT_TYPE Operation(FUNC fun, LEFT_TYPE left, RIGHT_TYPE right, ValidityMask &mask, idx_t idx) {
108406
+ if (left == NumericLimits<LEFT_TYPE>::Minimum() && right == -1) {
108407
+ throw OutOfRangeException("Overflow in division of %d / %d", left, right);
108408
+ } else if (right == 0) {
108409
+ mask.SetInvalid(idx);
108410
+ return left;
108411
+ } else {
108412
+ return OP::template Operation<LEFT_TYPE, RIGHT_TYPE, RESULT_TYPE>(left, right);
108413
+ }
108414
+ }
108415
+
108416
+ static bool AddsNulls() {
108417
+ return true;
108418
+ }
108419
+ };
108420
+
108383
108421
  struct BinaryZeroIsNullWrapper {
108384
108422
  template <class FUNC, class OP, class LEFT_TYPE, class RIGHT_TYPE, class RESULT_TYPE>
108385
108423
  static inline RESULT_TYPE Operation(FUNC fun, LEFT_TYPE left, RIGHT_TYPE right, ValidityMask &mask, idx_t idx) {
@@ -108421,13 +108459,13 @@ template <class OP>
108421
108459
  static scalar_function_t GetBinaryFunctionIgnoreZero(const LogicalType &type) {
108422
108460
  switch (type.id()) {
108423
108461
  case LogicalTypeId::TINYINT:
108424
- return BinaryScalarFunctionIgnoreZero<int8_t, int8_t, int8_t, OP>;
108462
+ return BinaryScalarFunctionIgnoreZero<int8_t, int8_t, int8_t, OP, BinaryNumericDivideWrapper>;
108425
108463
  case LogicalTypeId::SMALLINT:
108426
- return BinaryScalarFunctionIgnoreZero<int16_t, int16_t, int16_t, OP>;
108464
+ return BinaryScalarFunctionIgnoreZero<int16_t, int16_t, int16_t, OP, BinaryNumericDivideWrapper>;
108427
108465
  case LogicalTypeId::INTEGER:
108428
- return BinaryScalarFunctionIgnoreZero<int32_t, int32_t, int32_t, OP>;
108466
+ return BinaryScalarFunctionIgnoreZero<int32_t, int32_t, int32_t, OP, BinaryNumericDivideWrapper>;
108429
108467
  case LogicalTypeId::BIGINT:
108430
- return BinaryScalarFunctionIgnoreZero<int64_t, int64_t, int64_t, OP>;
108468
+ return BinaryScalarFunctionIgnoreZero<int64_t, int64_t, int64_t, OP, BinaryNumericDivideWrapper>;
108431
108469
  case LogicalTypeId::UTINYINT:
108432
108470
  return BinaryScalarFunctionIgnoreZero<uint8_t, uint8_t, uint8_t, OP>;
108433
108471
  case LogicalTypeId::USMALLINT:
@@ -114875,11 +114913,22 @@ static void CurrentSchemaFunction(DataChunk &input, ExpressionState &state, Vect
114875
114913
 
114876
114914
  // current_schemas
114877
114915
  static void CurrentSchemasFunction(DataChunk &input, ExpressionState &state, Vector &result) {
114916
+ if (!input.AllConstant()) {
114917
+ throw NotImplementedException("current_schemas requires a constant input");
114918
+ }
114919
+ if (ConstantVector::IsNull(input.data[0])) {
114920
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
114921
+ ConstantVector::SetNull(result, true);
114922
+ return;
114923
+ }
114924
+ auto implicit_schemas = *ConstantVector::GetData<bool>(input.data[0]);
114878
114925
  vector<Value> schema_list;
114879
- vector<string> search_path = ClientData::Get(SystemBindData::GetFrom(state).context).catalog_search_path->Get();
114926
+ auto &catalog_search_path = ClientData::Get(SystemBindData::GetFrom(state).context).catalog_search_path;
114927
+ vector<string> search_path = implicit_schemas ? catalog_search_path->Get() : catalog_search_path->GetSetPaths();
114880
114928
  std::transform(search_path.begin(), search_path.end(), std::back_inserter(schema_list),
114881
114929
  [](const string &s) -> Value { return Value(s); });
114882
- auto val = Value::LIST(schema_list);
114930
+
114931
+ auto val = Value::LIST(LogicalType::VARCHAR, schema_list);
114883
114932
  result.Reference(val);
114884
114933
  }
114885
114934
 
@@ -176415,7 +176464,7 @@ BindResult ExpressionBinder::BindMacro(FunctionExpression &function, ScalarMacro
176415
176464
  string error =
176416
176465
  MacroFunction::ValidateArguments(*macro_func->function, macro_func->name, function, positionals, defaults);
176417
176466
  if (!error.empty()) {
176418
- return BindResult(binder.FormatError(*expr->get(), error));
176467
+ throw BinderException(binder.FormatError(*expr->get(), error));
176419
176468
  }
176420
176469
 
176421
176470
  // create a MacroBinding to bind this macro's parameters to its arguments
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 "acbbd9317"
15
- #define DUCKDB_VERSION "v0.5.1-dev207"
14
+ #define DUCKDB_SOURCE_ID "140cc706d"
15
+ #define DUCKDB_VERSION "v0.5.1-dev216"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //