duckdb 0.3.4-dev7.0 → 0.3.4-dev75.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 +1 -1
- package/src/duckdb.cpp +51 -61
- package/src/duckdb.hpp +26 -6
- package/src/parquet-amalgamation.cpp +36719 -36719
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -68361,12 +68361,12 @@ void PartitionableHashTable::Partition() {
|
|
|
68361
68361
|
D_ASSERT(radix_partitioned_hts.size() == 0);
|
|
68362
68362
|
D_ASSERT(partition_info.n_partitions > 1);
|
|
68363
68363
|
|
|
68364
|
-
vector<GroupedAggregateHashTable *> partition_hts;
|
|
68364
|
+
vector<GroupedAggregateHashTable *> partition_hts(partition_info.n_partitions);
|
|
68365
68365
|
for (auto &unpartitioned_ht : unpartitioned_hts) {
|
|
68366
68366
|
for (idx_t r = 0; r < partition_info.n_partitions; r++) {
|
|
68367
68367
|
radix_partitioned_hts[r].push_back(make_unique<GroupedAggregateHashTable>(
|
|
68368
68368
|
buffer_manager, group_types, payload_types, bindings, HtEntryType::HT_WIDTH_32));
|
|
68369
|
-
partition_hts
|
|
68369
|
+
partition_hts[r] = radix_partitioned_hts[r].back().get();
|
|
68370
68370
|
}
|
|
68371
68371
|
unpartitioned_ht->Partition(partition_hts, partition_info.radix_mask, partition_info.RADIX_SHIFT);
|
|
68372
68372
|
unpartitioned_ht.reset();
|
|
@@ -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>
|
|
@@ -80015,6 +80017,9 @@ void HistogramFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
80015
80017
|
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_S));
|
|
80016
80018
|
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_MS));
|
|
80017
80019
|
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIMESTAMP_NS));
|
|
80020
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIME));
|
|
80021
|
+
fun.AddFunction(GetHistogramFunction<int64_t>(LogicalType::TIME_TZ));
|
|
80022
|
+
fun.AddFunction(GetHistogramFunction<int32_t>(LogicalType::DATE));
|
|
80018
80023
|
set.AddFunction(fun);
|
|
80019
80024
|
}
|
|
80020
80025
|
|
|
@@ -87821,6 +87826,10 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
|
|
|
87821
87826
|
VectorData value_data;
|
|
87822
87827
|
value_vector.Orrify(count, value_data);
|
|
87823
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
|
+
|
|
87824
87833
|
for (idx_t i = 0; i < count; i++) {
|
|
87825
87834
|
auto list_index = list_data.sel->get_index(i);
|
|
87826
87835
|
auto value_index = value_data.sel->get_index(i);
|
|
@@ -87831,23 +87840,18 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
|
|
|
87831
87840
|
}
|
|
87832
87841
|
|
|
87833
87842
|
const auto &list_entry = list_entries[list_index];
|
|
87834
|
-
auto source_idx = child_data.sel->get_index(list_entry.offset);
|
|
87835
87843
|
|
|
87836
|
-
|
|
87837
|
-
auto child_value = FlatVector::GetData<CHILD_TYPE>(child_vector);
|
|
87838
|
-
auto values = FlatVector::GetData<CHILD_TYPE>(value_vector);
|
|
87839
|
-
|
|
87840
|
-
result_entries[list_index] = OP::Initialize();
|
|
87844
|
+
result_entries[i] = OP::Initialize();
|
|
87841
87845
|
for (idx_t child_idx = 0; child_idx < list_entry.length; child_idx++) {
|
|
87842
|
-
auto child_value_idx = source_idx + child_idx;
|
|
87843
87846
|
|
|
87847
|
+
auto child_value_idx = child_data.sel->get_index(list_entry.offset + child_idx);
|
|
87844
87848
|
if (!child_data.validity.RowIsValid(child_value_idx)) {
|
|
87845
87849
|
continue;
|
|
87846
87850
|
}
|
|
87847
87851
|
|
|
87848
87852
|
if (!is_nested) {
|
|
87849
87853
|
if (ValueEqualsOrNot<CHILD_TYPE>(child_value[child_value_idx], values[value_index])) {
|
|
87850
|
-
result_entries[
|
|
87854
|
+
result_entries[i] = OP::UpdateResultEntries(child_idx);
|
|
87851
87855
|
break; // Found value in list, no need to look further
|
|
87852
87856
|
}
|
|
87853
87857
|
} else {
|
|
@@ -87855,7 +87859,7 @@ static void TemplatedContainsOrPosition(DataChunk &args, ExpressionState &state,
|
|
|
87855
87859
|
// to more efficiently compare nested types
|
|
87856
87860
|
if (ValueEqualsOrNot<Value>(child_vector.GetValue(child_value_idx),
|
|
87857
87861
|
value_vector.GetValue(value_index))) {
|
|
87858
|
-
result_entries[
|
|
87862
|
+
result_entries[i] = OP::UpdateResultEntries(child_idx);
|
|
87859
87863
|
break; // Found value in list, no need to look further
|
|
87860
87864
|
}
|
|
87861
87865
|
}
|
|
@@ -88274,10 +88278,7 @@ static void ListAggregateFunction(DataChunk &args, ExpressionState &state, Vecto
|
|
|
88274
88278
|
continue;
|
|
88275
88279
|
}
|
|
88276
88280
|
|
|
88277
|
-
|
|
88278
|
-
idx_t child_idx = 0;
|
|
88279
|
-
|
|
88280
|
-
while (child_idx < list_entry.length) {
|
|
88281
|
+
for (idx_t child_idx = 0; child_idx < list_entry.length; child_idx++) {
|
|
88281
88282
|
|
|
88282
88283
|
// states vector is full, update
|
|
88283
88284
|
if (states_idx == STANDARD_VECTOR_SIZE) {
|
|
@@ -88290,10 +88291,10 @@ static void ListAggregateFunction(DataChunk &args, ExpressionState &state, Vecto
|
|
|
88290
88291
|
states_idx = 0;
|
|
88291
88292
|
}
|
|
88292
88293
|
|
|
88293
|
-
|
|
88294
|
+
auto source_idx = child_data.sel->get_index(list_entry.offset + child_idx);
|
|
88295
|
+
sel_vector.set_index(states_idx, source_idx);
|
|
88294
88296
|
states_update[states_idx] = state_ptr;
|
|
88295
88297
|
states_idx++;
|
|
88296
|
-
child_idx++;
|
|
88297
88298
|
}
|
|
88298
88299
|
}
|
|
88299
88300
|
|
|
@@ -88330,7 +88331,7 @@ static unique_ptr<FunctionData> ListAggregateBind(ClientContext &context, Scalar
|
|
|
88330
88331
|
|
|
88331
88332
|
// get the function name
|
|
88332
88333
|
Value function_value = ExpressionExecutor::EvaluateScalar(*arguments[1]);
|
|
88333
|
-
auto function_name =
|
|
88334
|
+
auto function_name = function_value.ToString();
|
|
88334
88335
|
|
|
88335
88336
|
vector<LogicalType> types;
|
|
88336
88337
|
types.push_back(list_child_type);
|
|
@@ -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
|
-
|
|
129648
|
-
|
|
129649
|
-
|
|
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
|
-
//
|
|
129660
|
-
if (
|
|
129661
|
-
|
|
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
|
-
|
|
129665
|
-
|
|
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 =
|
|
129680
|
+
cast_type = LogicalType::UBIGINT;
|
|
129677
129681
|
} else {
|
|
129678
|
-
return
|
|
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(
|
|
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 (
|
|
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
|
|
129745
|
+
return TemplatedCastToSmallestType<hugeint_t>(move(expr), num_stats);
|
|
129760
129746
|
default:
|
|
129761
129747
|
throw NotImplementedException("Unknown integer type!");
|
|
129762
129748
|
}
|
|
@@ -170302,6 +170288,10 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, idx_t removed_co
|
|
|
170302
170288
|
D_ASSERT(removed_column < column_definitions.size());
|
|
170303
170289
|
column_definitions.erase(column_definitions.begin() + removed_column);
|
|
170304
170290
|
|
|
170291
|
+
for (idx_t i = 0; i < column_definitions.size(); i++) {
|
|
170292
|
+
column_definitions[i].oid = i;
|
|
170293
|
+
}
|
|
170294
|
+
|
|
170305
170295
|
// alter the row_groups and remove the column from each of them
|
|
170306
170296
|
this->row_groups = make_shared<SegmentTree>();
|
|
170307
170297
|
auto current_row_group = (RowGroup *)parent.row_groups->GetRootSegment();
|
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 "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.4-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "355e41717"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.4-dev75"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -2473,6 +2473,13 @@ public:
|
|
|
2473
2473
|
entry_idx = row_idx / BITS_PER_VALUE;
|
|
2474
2474
|
idx_in_entry = row_idx % BITS_PER_VALUE;
|
|
2475
2475
|
}
|
|
2476
|
+
//! Get an entry that has first-n bits set as valid and rest set as invalid
|
|
2477
|
+
static inline V EntryWithValidBits(idx_t n) {
|
|
2478
|
+
if (n == 0) {
|
|
2479
|
+
return V(0);
|
|
2480
|
+
}
|
|
2481
|
+
return ValidityBuffer::MAX_ENTRY >> (BITS_PER_VALUE - n);
|
|
2482
|
+
}
|
|
2476
2483
|
|
|
2477
2484
|
//! RowIsValidUnsafe should only be used if AllValid() is false: it achieves the same as RowIsValid but skips a
|
|
2478
2485
|
//! not-null check
|
|
@@ -2548,20 +2555,33 @@ public:
|
|
|
2548
2555
|
}
|
|
2549
2556
|
}
|
|
2550
2557
|
|
|
2551
|
-
//! Marks "count"
|
|
2558
|
+
//! Marks exactly "count" bits in the validity mask as invalid (null)
|
|
2552
2559
|
inline void SetAllInvalid(idx_t count) {
|
|
2553
2560
|
EnsureWritable();
|
|
2554
|
-
|
|
2561
|
+
if (count == 0) {
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
auto last_entry_index = ValidityBuffer::EntryCount(count) - 1;
|
|
2565
|
+
for (idx_t i = 0; i < last_entry_index; i++) {
|
|
2555
2566
|
validity_mask[i] = 0;
|
|
2556
2567
|
}
|
|
2568
|
+
auto last_entry_bits = count % static_cast<idx_t>(BITS_PER_VALUE);
|
|
2569
|
+
validity_mask[last_entry_index] = (last_entry_bits == 0) ? 0 : (ValidityBuffer::MAX_ENTRY << (last_entry_bits));
|
|
2557
2570
|
}
|
|
2558
2571
|
|
|
2559
|
-
//! Marks "count"
|
|
2572
|
+
//! Marks exactly "count" bits in the validity mask as valid (not null)
|
|
2560
2573
|
inline void SetAllValid(idx_t count) {
|
|
2561
2574
|
EnsureWritable();
|
|
2562
|
-
|
|
2575
|
+
if (count == 0) {
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
auto last_entry_index = ValidityBuffer::EntryCount(count) - 1;
|
|
2579
|
+
for (idx_t i = 0; i < last_entry_index; i++) {
|
|
2563
2580
|
validity_mask[i] = ValidityBuffer::MAX_ENTRY;
|
|
2564
2581
|
}
|
|
2582
|
+
auto last_entry_bits = count % static_cast<idx_t>(BITS_PER_VALUE);
|
|
2583
|
+
validity_mask[last_entry_index] |=
|
|
2584
|
+
(last_entry_bits == 0) ? ValidityBuffer::MAX_ENTRY : ~(ValidityBuffer::MAX_ENTRY << (last_entry_bits));
|
|
2565
2585
|
}
|
|
2566
2586
|
|
|
2567
2587
|
inline bool IsMaskSet() const {
|