duckdb 0.4.1-dev752.0 → 0.4.1-dev787.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 +179 -3
- package/src/duckdb.hpp +7 -6
- package/src/parquet-amalgamation.cpp +18761 -18761
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -45348,6 +45348,10 @@ struct MapFun {
|
|
|
45348
45348
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
45349
45349
|
};
|
|
45350
45350
|
|
|
45351
|
+
struct MapFromEntriesFun {
|
|
45352
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
|
45353
|
+
};
|
|
45354
|
+
|
|
45351
45355
|
struct MapExtractFun {
|
|
45352
45356
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
45353
45357
|
};
|
|
@@ -45416,6 +45420,7 @@ struct StructExtractFun {
|
|
|
45416
45420
|
|
|
45417
45421
|
MapInvalidReason CheckMapValidity(Vector &map, idx_t count,
|
|
45418
45422
|
const SelectionVector &sel = *FlatVector::IncrementalSelectionVector());
|
|
45423
|
+
void MapConversionVerify(Vector &vector, idx_t count);
|
|
45419
45424
|
|
|
45420
45425
|
} // namespace duckdb
|
|
45421
45426
|
|
|
@@ -98427,7 +98432,7 @@ MapInvalidReason CheckMapValidity(Vector &map, idx_t count, const SelectionVecto
|
|
|
98427
98432
|
return MapInvalidReason::VALID;
|
|
98428
98433
|
}
|
|
98429
98434
|
|
|
98430
|
-
|
|
98435
|
+
void MapConversionVerify(Vector &vector, idx_t count) {
|
|
98431
98436
|
auto valid_check = CheckMapValidity(vector, count);
|
|
98432
98437
|
switch (valid_check) {
|
|
98433
98438
|
case MapInvalidReason::VALID:
|
|
@@ -98608,6 +98613,176 @@ void MapExtractFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
98608
98613
|
}
|
|
98609
98614
|
|
|
98610
98615
|
} // namespace duckdb
|
|
98616
|
+
|
|
98617
|
+
|
|
98618
|
+
|
|
98619
|
+
|
|
98620
|
+
|
|
98621
|
+
|
|
98622
|
+
|
|
98623
|
+
namespace duckdb {
|
|
98624
|
+
|
|
98625
|
+
struct VectorInfo {
|
|
98626
|
+
Vector &container;
|
|
98627
|
+
list_entry_t &data;
|
|
98628
|
+
};
|
|
98629
|
+
|
|
98630
|
+
static void MapStruct(Value &element, VectorInfo &keys, VectorInfo &values) {
|
|
98631
|
+
D_ASSERT(element.type().id() == LogicalTypeId::STRUCT);
|
|
98632
|
+
D_ASSERT(!element.IsNull());
|
|
98633
|
+
auto &key_value = StructValue::GetChildren(element);
|
|
98634
|
+
auto &key = key_value[0];
|
|
98635
|
+
auto &value = key_value[1];
|
|
98636
|
+
|
|
98637
|
+
if (key.IsNull()) {
|
|
98638
|
+
throw InvalidInputException("None of the keys of the map can be NULL");
|
|
98639
|
+
}
|
|
98640
|
+
// Add to the inner key/value lists of the resulting map
|
|
98641
|
+
ListVector::PushBack(keys.container, key);
|
|
98642
|
+
ListVector::PushBack(values.container, value);
|
|
98643
|
+
}
|
|
98644
|
+
|
|
98645
|
+
// FIXME: this operation has a time complexity of O(n^2)
|
|
98646
|
+
void CheckKeyUniqueness(VectorInfo &keys) {
|
|
98647
|
+
auto end = keys.data.offset + keys.data.length;
|
|
98648
|
+
auto &entries = ListVector::GetEntry(keys.container);
|
|
98649
|
+
for (auto lhs = keys.data.offset; lhs < end; lhs++) {
|
|
98650
|
+
auto element = entries.GetValue(lhs);
|
|
98651
|
+
D_ASSERT(!element.IsNull());
|
|
98652
|
+
for (auto rhs = lhs + 1; rhs < end; rhs++) {
|
|
98653
|
+
auto other = entries.GetValue(rhs);
|
|
98654
|
+
D_ASSERT(!other.IsNull());
|
|
98655
|
+
|
|
98656
|
+
if (element.type() != other.type()) {
|
|
98657
|
+
throw InvalidInputException("Not all keys are of the same type!");
|
|
98658
|
+
}
|
|
98659
|
+
if (element == other) {
|
|
98660
|
+
throw InvalidInputException("The given keys aren't unique");
|
|
98661
|
+
}
|
|
98662
|
+
}
|
|
98663
|
+
}
|
|
98664
|
+
}
|
|
98665
|
+
|
|
98666
|
+
static bool MapSingleList(VectorInfo &input, VectorInfo &keys, VectorInfo &values) {
|
|
98667
|
+
// Get the length and offset of this list from the argument data
|
|
98668
|
+
auto pair_amount = input.data.length;
|
|
98669
|
+
auto input_offset = input.data.offset;
|
|
98670
|
+
|
|
98671
|
+
// Loop over the list of structs
|
|
98672
|
+
idx_t inserted_values = 0;
|
|
98673
|
+
for (idx_t i = 0; i < pair_amount; i++) {
|
|
98674
|
+
auto index = i + input_offset;
|
|
98675
|
+
// Get the struct using the offset and the index;
|
|
98676
|
+
auto element = input.container.GetValue(index);
|
|
98677
|
+
if (element.IsNull()) {
|
|
98678
|
+
continue;
|
|
98679
|
+
}
|
|
98680
|
+
MapStruct(element, keys, values);
|
|
98681
|
+
inserted_values++;
|
|
98682
|
+
}
|
|
98683
|
+
// Set the length of the key value lists
|
|
98684
|
+
keys.data.length = inserted_values;
|
|
98685
|
+
values.data.length = inserted_values;
|
|
98686
|
+
return inserted_values != 0;
|
|
98687
|
+
}
|
|
98688
|
+
|
|
98689
|
+
static void MapFromEntriesFunction(DataChunk &args, ExpressionState &state, Vector &result) {
|
|
98690
|
+
D_ASSERT(result.GetType().id() == LogicalTypeId::MAP);
|
|
98691
|
+
|
|
98692
|
+
result.SetVectorType(duckdb::VectorType::FLAT_VECTOR);
|
|
98693
|
+
|
|
98694
|
+
// Get the arguments vector
|
|
98695
|
+
auto &input_list = args.data[0];
|
|
98696
|
+
auto arg_data = FlatVector::GetData<list_entry_t>(input_list);
|
|
98697
|
+
auto &entries = ListVector::GetEntry(input_list);
|
|
98698
|
+
|
|
98699
|
+
// Prepare the result vectors
|
|
98700
|
+
auto &child_entries = StructVector::GetEntries(result);
|
|
98701
|
+
D_ASSERT(child_entries.size() == 2);
|
|
98702
|
+
auto &key_vector = *child_entries[0];
|
|
98703
|
+
auto &value_vector = *child_entries[1];
|
|
98704
|
+
auto &result_validity = FlatVector::Validity(result);
|
|
98705
|
+
|
|
98706
|
+
// Get the offset+length data for the list(s)
|
|
98707
|
+
auto key_data = FlatVector::GetData<list_entry_t>(key_vector);
|
|
98708
|
+
auto value_data = FlatVector::GetData<list_entry_t>(value_vector);
|
|
98709
|
+
|
|
98710
|
+
auto &key_validity = FlatVector::Validity(key_vector);
|
|
98711
|
+
auto &value_validity = FlatVector::Validity(value_vector);
|
|
98712
|
+
|
|
98713
|
+
auto count = args.size();
|
|
98714
|
+
|
|
98715
|
+
UnifiedVectorFormat input_list_data;
|
|
98716
|
+
input_list.ToUnifiedFormat(count, input_list_data);
|
|
98717
|
+
|
|
98718
|
+
// Current offset into the keys/values list
|
|
98719
|
+
idx_t offset = 0;
|
|
98720
|
+
|
|
98721
|
+
// Transform to mapped values
|
|
98722
|
+
for (idx_t i = 0; i < count; i++) {
|
|
98723
|
+
VectorInfo input {entries, arg_data[i]};
|
|
98724
|
+
VectorInfo keys {key_vector, key_data[i]};
|
|
98725
|
+
VectorInfo values {value_vector, value_data[i]};
|
|
98726
|
+
|
|
98727
|
+
keys.data.offset = offset;
|
|
98728
|
+
values.data.offset = offset;
|
|
98729
|
+
auto row_valid = MapSingleList(input, keys, values);
|
|
98730
|
+
offset += keys.data.length;
|
|
98731
|
+
|
|
98732
|
+
// Check validity
|
|
98733
|
+
if (!row_valid || !input_list_data.validity.RowIsValid(i)) {
|
|
98734
|
+
key_validity.SetInvalid(i);
|
|
98735
|
+
value_validity.SetInvalid(i);
|
|
98736
|
+
result_validity.SetInvalid(i);
|
|
98737
|
+
}
|
|
98738
|
+
}
|
|
98739
|
+
MapConversionVerify(result, count);
|
|
98740
|
+
result.Verify(count);
|
|
98741
|
+
}
|
|
98742
|
+
|
|
98743
|
+
static unique_ptr<FunctionData> MapFromEntriesBind(ClientContext &context, ScalarFunction &bound_function,
|
|
98744
|
+
vector<unique_ptr<Expression>> &arguments) {
|
|
98745
|
+
child_list_t<LogicalType> child_types;
|
|
98746
|
+
|
|
98747
|
+
if (arguments.size() != 1) {
|
|
98748
|
+
throw InvalidInputException("The input argument must be a list of structs.");
|
|
98749
|
+
}
|
|
98750
|
+
auto &list = arguments[0]->return_type;
|
|
98751
|
+
|
|
98752
|
+
if (list.id() == LogicalTypeId::UNKNOWN) {
|
|
98753
|
+
bound_function.arguments.emplace_back(LogicalTypeId::UNKNOWN);
|
|
98754
|
+
bound_function.return_type = LogicalType(LogicalTypeId::SQLNULL);
|
|
98755
|
+
return nullptr;
|
|
98756
|
+
}
|
|
98757
|
+
|
|
98758
|
+
if (list.id() != LogicalTypeId::LIST) {
|
|
98759
|
+
throw InvalidInputException("The provided argument is not a list of structs");
|
|
98760
|
+
}
|
|
98761
|
+
auto &elem_type = ListType::GetChildType(list);
|
|
98762
|
+
if (elem_type.id() != LogicalTypeId::STRUCT) {
|
|
98763
|
+
throw InvalidInputException("The elements of the list must be structs");
|
|
98764
|
+
}
|
|
98765
|
+
auto &children = StructType::GetChildTypes(elem_type);
|
|
98766
|
+
if (children.size() != 2) {
|
|
98767
|
+
throw InvalidInputException("The provided struct type should only contain 2 fields, a key and a value");
|
|
98768
|
+
}
|
|
98769
|
+
child_types.push_back(make_pair("key", LogicalType::LIST(children[0].second)));
|
|
98770
|
+
child_types.push_back(make_pair("value", LogicalType::LIST(children[1].second)));
|
|
98771
|
+
|
|
98772
|
+
//! this is more for completeness reasons
|
|
98773
|
+
bound_function.return_type = LogicalType::MAP(move(child_types));
|
|
98774
|
+
return make_unique<VariableReturnBindData>(bound_function.return_type);
|
|
98775
|
+
}
|
|
98776
|
+
|
|
98777
|
+
void MapFromEntriesFun::RegisterFunction(BuiltinFunctions &set) {
|
|
98778
|
+
//! the arguments and return types are actually set in the binder function
|
|
98779
|
+
ScalarFunction fun("map_from_entries", {}, LogicalTypeId::MAP, MapFromEntriesFunction, MapFromEntriesBind);
|
|
98780
|
+
fun.null_handling = FunctionNullHandling::DEFAULT_NULL_HANDLING;
|
|
98781
|
+
fun.varargs = LogicalType::ANY;
|
|
98782
|
+
set.AddFunction(fun);
|
|
98783
|
+
}
|
|
98784
|
+
|
|
98785
|
+
} // namespace duckdb
|
|
98611
98786
|
//===----------------------------------------------------------------------===//
|
|
98612
98787
|
// DuckDB
|
|
98613
98788
|
//
|
|
@@ -100127,6 +100302,7 @@ void BuiltinFunctions::RegisterNestedFunctions() {
|
|
|
100127
100302
|
Register<ListRangeFun>();
|
|
100128
100303
|
Register<ListFlattenFun>();
|
|
100129
100304
|
Register<MapFun>();
|
|
100305
|
+
Register<MapFromEntriesFun>();
|
|
100130
100306
|
Register<MapExtractFun>();
|
|
100131
100307
|
Register<CardinalityFun>();
|
|
100132
100308
|
}
|
|
@@ -105855,8 +106031,8 @@ static unique_ptr<FunctionData> StructExtractBind(ClientContext &context, Scalar
|
|
|
105855
106031
|
if (key_child->HasParameter()) {
|
|
105856
106032
|
throw ParameterNotResolvedException();
|
|
105857
106033
|
}
|
|
105858
|
-
|
|
105859
|
-
|
|
106034
|
+
|
|
106035
|
+
if (key_child->return_type.id() != LogicalTypeId::VARCHAR || !key_child->IsFoldable()) {
|
|
105860
106036
|
throw BinderException("Key name for struct_extract needs to be a constant string");
|
|
105861
106037
|
}
|
|
105862
106038
|
Value key_val = ExpressionExecutor::EvaluateScalar(*key_child.get());
|
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.4.1-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "cafd60e6b"
|
|
15
|
+
#define DUCKDB_VERSION "v0.4.1-dev787"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -3325,7 +3325,7 @@ public:
|
|
|
3325
3325
|
DUCKDB_API Allocator(allocate_function_ptr_t allocate_function_p, free_function_ptr_t free_function_p,
|
|
3326
3326
|
reallocate_function_ptr_t reallocate_function_p,
|
|
3327
3327
|
unique_ptr<PrivateAllocatorData> private_data);
|
|
3328
|
-
|
|
3328
|
+
Allocator &operator=(Allocator &&allocator) noexcept = delete;
|
|
3329
3329
|
DUCKDB_API ~Allocator();
|
|
3330
3330
|
|
|
3331
3331
|
data_ptr_t AllocateData(idx_t size);
|
|
@@ -3656,8 +3656,8 @@ public:
|
|
|
3656
3656
|
DUCKDB_API BufferHandle(shared_ptr<BlockHandle> handle, FileBuffer *node);
|
|
3657
3657
|
DUCKDB_API ~BufferHandle();
|
|
3658
3658
|
// disable copy constructors
|
|
3659
|
-
|
|
3660
|
-
|
|
3659
|
+
BufferHandle(const BufferHandle &other) = delete;
|
|
3660
|
+
BufferHandle &operator=(const BufferHandle &) = delete;
|
|
3661
3661
|
//! enable move constructors
|
|
3662
3662
|
DUCKDB_API BufferHandle(BufferHandle &&other) noexcept;
|
|
3663
3663
|
DUCKDB_API BufferHandle &operator=(BufferHandle &&) noexcept;
|
|
@@ -6656,6 +6656,7 @@ class TableFunction;
|
|
|
6656
6656
|
|
|
6657
6657
|
struct PragmaInfo;
|
|
6658
6658
|
|
|
6659
|
+
//! The default null handling is NULL in, NULL out
|
|
6659
6660
|
enum class FunctionNullHandling : uint8_t { DEFAULT_NULL_HANDLING = 0, SPECIAL_HANDLING = 1 };
|
|
6660
6661
|
enum class FunctionSideEffects : uint8_t { NO_SIDE_EFFECTS = 0, HAS_SIDE_EFFECTS = 1 };
|
|
6661
6662
|
|
|
@@ -11986,7 +11987,7 @@ public:
|
|
|
11986
11987
|
DUCKDB_API ColumnDependencyManager();
|
|
11987
11988
|
DUCKDB_API ~ColumnDependencyManager();
|
|
11988
11989
|
DUCKDB_API ColumnDependencyManager(ColumnDependencyManager &&other) = default;
|
|
11989
|
-
|
|
11990
|
+
ColumnDependencyManager(const ColumnDependencyManager &other) = delete;
|
|
11990
11991
|
|
|
11991
11992
|
public:
|
|
11992
11993
|
//! Get the bind order that ensures dependencies are resolved before dependents are
|