duckdb 0.3.4-dev70.0 → 0.3.4-dev77.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.4-dev70.0",
4
+ "version": "0.3.4-dev77.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -68845,6 +68845,8 @@ template <>
68845
68845
  bool TrySubtractOperator::Operation(int32_t left, int32_t right, int32_t &result);
68846
68846
  template <>
68847
68847
  bool TrySubtractOperator::Operation(int64_t left, int64_t right, int64_t &result);
68848
+ template <>
68849
+ bool TrySubtractOperator::Operation(hugeint_t left, hugeint_t right, hugeint_t &result);
68848
68850
 
68849
68851
  struct SubtractOperatorOverflowCheck {
68850
68852
  template <class TA, class TB, class TR>
@@ -87824,6 +87826,10 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
87824
87826
  VectorData value_data;
87825
87827
  value_vector.Orrify(count, value_data);
87826
87828
 
87829
+ // not required for a comparison of nested types
87830
+ auto child_value = FlatVector::GetData<CHILD_TYPE>(child_vector);
87831
+ auto values = FlatVector::GetData<CHILD_TYPE>(value_vector);
87832
+
87827
87833
  for (idx_t i = 0; i < count; i++) {
87828
87834
  auto list_index = list_data.sel->get_index(i);
87829
87835
  auto value_index = value_data.sel->get_index(i);
@@ -87834,23 +87840,18 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
87834
87840
  }
87835
87841
 
87836
87842
  const auto &list_entry = list_entries[list_index];
87837
- auto source_idx = child_data.sel->get_index(list_entry.offset);
87838
87843
 
87839
- // not required for a comparison of nested types
87840
- auto child_value = FlatVector::GetData<CHILD_TYPE>(child_vector);
87841
- auto values = FlatVector::GetData<CHILD_TYPE>(value_vector);
87842
-
87843
- result_entries[list_index] = OP::Initialize();
87844
+ result_entries[i] = OP::Initialize();
87844
87845
  for (idx_t child_idx = 0; child_idx < list_entry.length; child_idx++) {
87845
- auto child_value_idx = source_idx + child_idx;
87846
87846
 
87847
+ auto child_value_idx = child_data.sel->get_index(list_entry.offset + child_idx);
87847
87848
  if (!child_data.validity.RowIsValid(child_value_idx)) {
87848
87849
  continue;
87849
87850
  }
87850
87851
 
87851
87852
  if (!is_nested) {
87852
87853
  if (ValueEqualsOrNot<CHILD_TYPE>(child_value[child_value_idx], values[value_index])) {
87853
- result_entries[list_index] = OP::UpdateResultEntries(child_idx);
87854
+ result_entries[i] = OP::UpdateResultEntries(child_idx);
87854
87855
  break; // Found value in list, no need to look further
87855
87856
  }
87856
87857
  } else {
@@ -87858,7 +87859,7 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
87858
87859
  // to more efficiently compare nested types
87859
87860
  if (ValueEqualsOrNot<Value>(child_vector.GetValue(child_value_idx),
87860
87861
  value_vector.GetValue(value_index))) {
87861
- result_entries[list_index] = OP::UpdateResultEntries(child_idx);
87862
+ result_entries[i] = OP::UpdateResultEntries(child_idx);
87862
87863
  break; // Found value in list, no need to look further
87863
87864
  }
87864
87865
  }
@@ -92442,6 +92443,12 @@ bool TrySubtractOperator::Operation(int64_t left, int64_t right, int64_t &result
92442
92443
  return true;
92443
92444
  }
92444
92445
 
92446
+ template <>
92447
+ bool TrySubtractOperator::Operation(hugeint_t left, hugeint_t right, hugeint_t &result) {
92448
+ result = left;
92449
+ return Hugeint::SubtractInPlace(result, right);
92450
+ }
92451
+
92445
92452
  //===--------------------------------------------------------------------===//
92446
92453
  // subtract decimal with overflow check
92447
92454
  //===--------------------------------------------------------------------===//
@@ -129644,28 +129651,25 @@ unique_ptr<BaseStatistics> StatisticsPropagator::PropagateExpression(BoundAggreg
129644
129651
 
129645
129652
  namespace duckdb {
129646
129653
 
129647
- unique_ptr<Expression> CastHugeintToSmallestType(unique_ptr<Expression> expr, NumericStatistics &num_stats) {
129648
- // Compute range
129649
- if (num_stats.min.IsNull() || num_stats.max.IsNull()) {
129650
- return expr;
129651
- }
129652
-
129653
- auto min_val = num_stats.min.GetValue<hugeint_t>();
129654
- auto max_val = num_stats.max.GetValue<hugeint_t>();
129655
- if (max_val < min_val) {
129656
- return expr;
129657
- }
129654
+ template <class T>
129655
+ bool GetCastType(T signed_range, LogicalType &cast_type) {
129656
+ auto range = static_cast<typename std::make_unsigned<decltype(signed_range)>::type>(signed_range);
129658
129657
 
129659
- // Prevent overflow
129660
- if (min_val < NumericLimits<int64_t>().Minimum() && max_val > NumericLimits<int64_t>().Maximum()) {
129661
- return expr;
129658
+ // Check if this range fits in a smaller type
129659
+ if (range < NumericLimits<uint8_t>::Maximum()) {
129660
+ cast_type = LogicalType::UTINYINT;
129661
+ } else if (sizeof(T) > sizeof(uint16_t) && range < NumericLimits<uint16_t>::Maximum()) {
129662
+ cast_type = LogicalType::USMALLINT;
129663
+ } else if (sizeof(T) > sizeof(uint32_t) && range < NumericLimits<uint32_t>::Maximum()) {
129664
+ cast_type = LogicalType::UINTEGER;
129665
+ } else {
129666
+ return false;
129662
129667
  }
129668
+ return true;
129669
+ }
129663
129670
 
129664
- // Compute range
129665
- auto range = max_val - min_val;
129666
-
129667
- // Check if this range fits in a smaller type
129668
- LogicalType cast_type;
129671
+ template <>
129672
+ bool GetCastType(hugeint_t range, LogicalType &cast_type) {
129669
129673
  if (range < NumericLimits<uint8_t>().Maximum()) {
129670
129674
  cast_type = LogicalType::UTINYINT;
129671
129675
  } else if (range < NumericLimits<uint16_t>().Maximum()) {
@@ -129673,22 +129677,11 @@ unique_ptr<Expression> CastHugeintToSmallestType(unique_ptr<Expression> expr, Nu
129673
129677
  } else if (range < NumericLimits<uint32_t>().Maximum()) {
129674
129678
  cast_type = LogicalType::UINTEGER;
129675
129679
  } else if (range < NumericLimits<uint64_t>().Maximum()) {
129676
- cast_type = LogicalTypeId::UBIGINT;
129680
+ cast_type = LogicalType::UBIGINT;
129677
129681
  } else {
129678
- return expr;
129682
+ return false;
129679
129683
  }
129680
-
129681
- // Create expression to map to a smaller range
129682
- auto input_type = expr->return_type;
129683
- auto minimum_expr = make_unique<BoundConstantExpression>(Value::CreateValue(min_val));
129684
- vector<unique_ptr<Expression>> arguments;
129685
- arguments.push_back(move(expr));
129686
- arguments.push_back(move(minimum_expr));
129687
- auto minus_expr = make_unique<BoundFunctionExpression>(input_type, SubtractFun::GetFunction(input_type, input_type),
129688
- move(arguments), nullptr, true);
129689
-
129690
- // Cast to smaller type
129691
- return make_unique<BoundCastExpression>(move(minus_expr), cast_type);
129684
+ return true;
129692
129685
  }
129693
129686
 
129694
129687
  template <class T>
@@ -129706,21 +129699,14 @@ unique_ptr<Expression> TemplatedCastToSmallestType(unique_ptr<Expression> expr,
129706
129699
 
129707
129700
  // Compute range, cast to unsigned to prevent comparing signed with unsigned
129708
129701
  T signed_range;
129709
- if (!TrySubtractOperator::Operation(signed_min_val, signed_max_val, signed_range)) {
129702
+ if (!TrySubtractOperator::Operation(signed_max_val, signed_min_val, signed_range)) {
129710
129703
  // overflow in subtraction: cannot do any simplification
129711
129704
  return expr;
129712
129705
  }
129713
- auto range = static_cast<typename std::make_unsigned<decltype(signed_range)>::type>(signed_range);
129714
129706
 
129715
129707
  // Check if this range fits in a smaller type
129716
129708
  LogicalType cast_type;
129717
- if (range < NumericLimits<uint8_t>::Maximum()) {
129718
- cast_type = LogicalType::UTINYINT;
129719
- } else if (sizeof(T) > sizeof(uint16_t) && range < NumericLimits<uint16_t>::Maximum()) {
129720
- cast_type = LogicalType::USMALLINT;
129721
- } else if (sizeof(T) > sizeof(uint32_t) && range < NumericLimits<uint32_t>::Maximum()) {
129722
- cast_type = LogicalType::UINTEGER;
129723
- } else {
129709
+ if (!GetCastType(signed_range, cast_type)) {
129724
129710
  return expr;
129725
129711
  }
129726
129712
 
@@ -129756,7 +129742,7 @@ unique_ptr<Expression> CastToSmallestType(unique_ptr<Expression> expr, NumericSt
129756
129742
  case PhysicalType::INT64:
129757
129743
  return TemplatedCastToSmallestType<int64_t>(move(expr), num_stats);
129758
129744
  case PhysicalType::INT128:
129759
- return CastHugeintToSmallestType(move(expr), num_stats);
129745
+ return TemplatedCastToSmallestType<hugeint_t>(move(expr), num_stats);
129760
129746
  default:
129761
129747
  throw NotImplementedException("Unknown integer type!");
129762
129748
  }
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 "f63df22eb"
15
- #define DUCKDB_VERSION "v0.3.4-dev70"
14
+ #define DUCKDB_SOURCE_ID "6f659fd98"
15
+ #define DUCKDB_VERSION "v0.3.4-dev77"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //