duckdb 0.6.2-dev919.0 → 0.6.2-dev942.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/extension/json/json_functions/json_create.cpp +6 -12
- package/src/duckdb/extension/parquet/column_writer.cpp +6 -5
- package/src/duckdb/extension/parquet/parquet_reader.cpp +6 -8
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -15
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -5
- package/src/duckdb/src/common/row_operations/row_gather.cpp +0 -1
- package/src/duckdb/src/common/row_operations/row_match.cpp +0 -1
- package/src/duckdb/src/common/row_operations/row_scatter.cpp +0 -2
- package/src/duckdb/src/common/sort/sort_state.cpp +0 -2
- package/src/duckdb/src/common/types/value.cpp +6 -8
- package/src/duckdb/src/common/types/vector.cpp +40 -43
- package/src/duckdb/src/common/types.cpp +20 -25
- package/src/duckdb/src/common/vector_operations/comparison_operators.cpp +0 -1
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +0 -2
- package/src/duckdb/src/common/vector_operations/vector_hash.cpp +0 -2
- package/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +0 -1
- package/src/duckdb/src/execution/window_segment_tree.cpp +0 -17
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +22 -0
- package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +0 -1
- package/src/duckdb/src/function/aggregate/nested/histogram.cpp +7 -24
- package/src/duckdb/src/function/cast/list_casts.cpp +3 -3
- package/src/duckdb/src/function/cast/map_cast.cpp +19 -60
- package/src/duckdb/src/function/scalar/list/contains_or_position.cpp +0 -1
- package/src/duckdb/src/function/scalar/map/cardinality.cpp +1 -4
- package/src/duckdb/src/function/scalar/map/map.cpp +26 -38
- package/src/duckdb/src/function/scalar/map/map_extract.cpp +7 -6
- package/src/duckdb/src/function/scalar/map/map_from_entries.cpp +2 -117
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +1 -1
- package/src/duckdb/src/function/table/arrow.cpp +6 -10
- package/src/duckdb/src/function/table/arrow_conversion.cpp +2 -55
- package/src/duckdb/src/function/table/system/test_all_types.cpp +14 -3
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types.hpp +1 -3
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +4 -0
- package/src/duckdb/src/main/capi/logical_types-c.cpp +3 -2
- package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +1 -8
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +11 -9
- package/src/duckdb/src/planner/expression_binder.cpp +6 -6
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
|
@@ -177,9 +177,20 @@ vector<TestType> TestAllTypesFun::GetTestTypes() {
|
|
|
177
177
|
|
|
178
178
|
// map
|
|
179
179
|
auto map_type = LogicalType::MAP(LogicalType::VARCHAR, LogicalType::VARCHAR);
|
|
180
|
-
auto min_map_value = Value::MAP(
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
auto min_map_value = Value::MAP(ListType::GetChildType(map_type), std::vector<Value>());
|
|
181
|
+
|
|
182
|
+
child_list_t<Value> map_struct1;
|
|
183
|
+
map_struct1.push_back(make_pair("key", Value("key1")));
|
|
184
|
+
map_struct1.push_back(make_pair("value", Value("🦆🦆🦆🦆🦆🦆")));
|
|
185
|
+
child_list_t<Value> map_struct2;
|
|
186
|
+
map_struct2.push_back(make_pair("key", Value("key2")));
|
|
187
|
+
map_struct2.push_back(make_pair("key", Value("goose")));
|
|
188
|
+
|
|
189
|
+
std::vector<Value> map_values;
|
|
190
|
+
map_values.push_back(Value::STRUCT(map_struct1));
|
|
191
|
+
map_values.push_back(Value::STRUCT(map_struct2));
|
|
192
|
+
|
|
193
|
+
auto max_map_value = Value::MAP(ListType::GetChildType(map_type), map_values);
|
|
183
194
|
result.emplace_back(map_type, "map", move(min_map_value), move(max_map_value));
|
|
184
195
|
|
|
185
196
|
return result;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev942"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "2dcdc24556"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -157,8 +157,8 @@ public:
|
|
|
157
157
|
DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
|
|
158
158
|
//! Create an empty list with the specified child-type
|
|
159
159
|
DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
|
|
160
|
-
//! Create a map value
|
|
161
|
-
DUCKDB_API static Value MAP(
|
|
160
|
+
//! Create a map value with the given entries
|
|
161
|
+
DUCKDB_API static Value MAP(LogicalType child_type, vector<Value> values);
|
|
162
162
|
//! Create a union value from a selected value and a tag from a set of alternatives.
|
|
163
163
|
DUCKDB_API static Value UNION(child_list_t<LogicalType> members, uint8_t tag, Value value);
|
|
164
164
|
|
|
@@ -304,6 +304,7 @@ struct FlatVector {
|
|
|
304
304
|
return !vector.validity.RowIsValid(idx);
|
|
305
305
|
}
|
|
306
306
|
DUCKDB_API static const SelectionVector *IncrementalSelectionVector();
|
|
307
|
+
static Value GetValuesFromOffsets(Vector &values, vector<idx_t> &offsets);
|
|
307
308
|
};
|
|
308
309
|
|
|
309
310
|
struct ListVector {
|
|
@@ -330,8 +331,6 @@ struct ListVector {
|
|
|
330
331
|
DUCKDB_API static void Append(Vector &target, const Vector &source, const SelectionVector &sel, idx_t source_size,
|
|
331
332
|
idx_t source_offset = 0);
|
|
332
333
|
DUCKDB_API static void PushBack(Vector &target, const Value &insert);
|
|
333
|
-
DUCKDB_API static vector<idx_t> Search(Vector &list, const Value &key, idx_t row);
|
|
334
|
-
DUCKDB_API static Value GetValuesFromOffsets(Vector &list, vector<idx_t> &offsets);
|
|
335
334
|
//! Share the entry of the other list vector
|
|
336
335
|
DUCKDB_API static void ReferenceEntry(Vector &vector, Vector &other);
|
|
337
336
|
};
|
|
@@ -409,6 +408,7 @@ struct MapVector {
|
|
|
409
408
|
DUCKDB_API static const Vector &GetValues(const Vector &vector);
|
|
410
409
|
DUCKDB_API static Vector &GetKeys(Vector &vector);
|
|
411
410
|
DUCKDB_API static Vector &GetValues(Vector &vector);
|
|
411
|
+
static vector<idx_t> Search(Vector &keys, idx_t count, const Value &key, list_entry_t &entry);
|
|
412
412
|
};
|
|
413
413
|
|
|
414
414
|
struct StructVector {
|
|
@@ -195,9 +195,6 @@ enum class PhysicalType : uint8_t {
|
|
|
195
195
|
///// ArrayData struct
|
|
196
196
|
//DICTIONARY = 26,
|
|
197
197
|
|
|
198
|
-
/// Map, a repeated struct logical type
|
|
199
|
-
MAP = 27,
|
|
200
|
-
|
|
201
198
|
///// Custom data type, implemented by user
|
|
202
199
|
//EXTENSION = 28,
|
|
203
200
|
|
|
@@ -410,6 +407,7 @@ public:
|
|
|
410
407
|
DUCKDB_API static LogicalType LIST( LogicalType child); // NOLINT
|
|
411
408
|
DUCKDB_API static LogicalType STRUCT( child_list_t<LogicalType> children); // NOLINT
|
|
412
409
|
DUCKDB_API static LogicalType AGGREGATE_STATE(aggregate_state_t state_type); // NOLINT
|
|
410
|
+
DUCKDB_API static LogicalType MAP(LogicalType child); // NOLINT
|
|
413
411
|
DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
|
|
414
412
|
DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
|
|
415
413
|
DUCKDB_API static LogicalType UNION( child_list_t<LogicalType> members); // NOLINT
|
|
@@ -83,6 +83,10 @@ public:
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
struct ListCast {
|
|
87
|
+
static bool ListToListCast(Vector &source, Vector &result, idx_t count, CastParameters ¶meters);
|
|
88
|
+
};
|
|
89
|
+
|
|
86
90
|
struct StructBoundCastData : public BoundCastData {
|
|
87
91
|
StructBoundCastData(vector<BoundCastInfo> child_casts, LogicalType target_p)
|
|
88
92
|
: child_cast_info(move(child_casts)), target(move(target_p)) {
|
|
@@ -151,11 +151,12 @@ char *duckdb_enum_dictionary_value(duckdb_logical_type type, idx_t index) {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
duckdb_logical_type duckdb_list_type_child_type(duckdb_logical_type type) {
|
|
154
|
-
if (!AssertLogicalTypeId(type, duckdb::LogicalTypeId::LIST)
|
|
154
|
+
if (!AssertLogicalTypeId(type, duckdb::LogicalTypeId::LIST) &&
|
|
155
|
+
!AssertLogicalTypeId(type, duckdb::LogicalTypeId::MAP)) {
|
|
155
156
|
return nullptr;
|
|
156
157
|
}
|
|
157
158
|
auto <ype = *((duckdb::LogicalType *)type);
|
|
158
|
-
if (ltype.id() != duckdb::LogicalTypeId::LIST) {
|
|
159
|
+
if (ltype.id() != duckdb::LogicalTypeId::LIST && ltype.id() != duckdb::LogicalTypeId::MAP) {
|
|
159
160
|
return nullptr;
|
|
160
161
|
}
|
|
161
162
|
return reinterpret_cast<duckdb_logical_type>(new duckdb::LogicalType(duckdb::ListType::GetChildType(ltype)));
|
|
@@ -54,21 +54,14 @@ LogicalType Transformer::TransformTypeName(duckdb_libpgquery::PGTypeName *type_n
|
|
|
54
54
|
D_ASSERT(!children.empty());
|
|
55
55
|
result_type = LogicalType::STRUCT(move(children));
|
|
56
56
|
} else if (base_type == LogicalTypeId::MAP) {
|
|
57
|
-
//! We transform MAP<TYPE_KEY, TYPE_VALUE> to STRUCT<LIST<key: TYPE_KEY>, LIST<value: TYPE_VALUE>>
|
|
58
57
|
|
|
59
58
|
if (!type_name->typmods || type_name->typmods->length != 2) {
|
|
60
59
|
throw ParserException("Map type needs exactly two entries, key and value type");
|
|
61
60
|
}
|
|
62
|
-
child_list_t<LogicalType> children;
|
|
63
61
|
auto key_type = TransformTypeName((duckdb_libpgquery::PGTypeName *)type_name->typmods->head->data.ptr_value);
|
|
64
62
|
auto value_type = TransformTypeName((duckdb_libpgquery::PGTypeName *)type_name->typmods->tail->data.ptr_value);
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
children.push_back({"value", LogicalType::LIST(value_type)});
|
|
68
|
-
|
|
69
|
-
D_ASSERT(children.size() == 2);
|
|
70
|
-
|
|
71
|
-
result_type = LogicalType::MAP(move(children));
|
|
64
|
+
result_type = LogicalType::MAP(move(key_type), move(value_type));
|
|
72
65
|
} else if (base_type == LogicalTypeId::UNION) {
|
|
73
66
|
if (!type_name->typmods || type_name->typmods->length == 0) {
|
|
74
67
|
throw ParserException("Union type needs at least one member");
|
|
@@ -176,24 +176,26 @@ SchemaCatalogEntry *Binder::BindCreateFunctionInfo(CreateInfo &info) {
|
|
|
176
176
|
}
|
|
177
177
|
|
|
178
178
|
void Binder::BindLogicalType(ClientContext &context, LogicalType &type, const string &catalog, const string &schema) {
|
|
179
|
-
if (type.id() == LogicalTypeId::LIST) {
|
|
179
|
+
if (type.id() == LogicalTypeId::LIST || type.id() == LogicalTypeId::MAP) {
|
|
180
180
|
auto child_type = ListType::GetChildType(type);
|
|
181
181
|
BindLogicalType(context, child_type, catalog, schema);
|
|
182
182
|
auto alias = type.GetAlias();
|
|
183
|
-
type
|
|
183
|
+
if (type.id() == LogicalTypeId::LIST) {
|
|
184
|
+
type = LogicalType::LIST(child_type);
|
|
185
|
+
} else {
|
|
186
|
+
D_ASSERT(child_type.id() == LogicalTypeId::STRUCT); // map must be list of structs
|
|
187
|
+
type = LogicalType::MAP(child_type);
|
|
188
|
+
}
|
|
189
|
+
|
|
184
190
|
type.SetAlias(alias);
|
|
185
|
-
} else if (type.id() == LogicalTypeId::STRUCT
|
|
191
|
+
} else if (type.id() == LogicalTypeId::STRUCT) {
|
|
186
192
|
auto child_types = StructType::GetChildTypes(type);
|
|
187
193
|
for (auto &child_type : child_types) {
|
|
188
194
|
BindLogicalType(context, child_type.second, catalog, schema);
|
|
189
195
|
}
|
|
190
|
-
// Generate new Struct
|
|
196
|
+
// Generate new Struct Type
|
|
191
197
|
auto alias = type.GetAlias();
|
|
192
|
-
|
|
193
|
-
type = LogicalType::STRUCT(child_types);
|
|
194
|
-
} else {
|
|
195
|
-
type = LogicalType::MAP(child_types);
|
|
196
|
-
}
|
|
198
|
+
type = LogicalType::STRUCT(child_types);
|
|
197
199
|
type.SetAlias(alias);
|
|
198
200
|
} else if (type.id() == LogicalTypeId::UNION) {
|
|
199
201
|
auto member_types = UnionType::CopyMemberTypes(type);
|
|
@@ -120,8 +120,7 @@ bool ExpressionBinder::ContainsType(const LogicalType &type, LogicalTypeId targe
|
|
|
120
120
|
return true;
|
|
121
121
|
}
|
|
122
122
|
switch (type.id()) {
|
|
123
|
-
case LogicalTypeId::STRUCT:
|
|
124
|
-
case LogicalTypeId::MAP: {
|
|
123
|
+
case LogicalTypeId::STRUCT: {
|
|
125
124
|
auto child_count = StructType::GetChildCount(type);
|
|
126
125
|
for (idx_t i = 0; i < child_count; i++) {
|
|
127
126
|
if (ContainsType(StructType::GetChildType(type, i), target)) {
|
|
@@ -140,6 +139,7 @@ bool ExpressionBinder::ContainsType(const LogicalType &type, LogicalTypeId targe
|
|
|
140
139
|
return false;
|
|
141
140
|
}
|
|
142
141
|
case LogicalTypeId::LIST:
|
|
142
|
+
case LogicalTypeId::MAP:
|
|
143
143
|
return ContainsType(ListType::GetChildType(type), target);
|
|
144
144
|
default:
|
|
145
145
|
return false;
|
|
@@ -151,15 +151,13 @@ LogicalType ExpressionBinder::ExchangeType(const LogicalType &type, LogicalTypeI
|
|
|
151
151
|
return new_type;
|
|
152
152
|
}
|
|
153
153
|
switch (type.id()) {
|
|
154
|
-
case LogicalTypeId::STRUCT:
|
|
155
|
-
case LogicalTypeId::MAP: {
|
|
154
|
+
case LogicalTypeId::STRUCT: {
|
|
156
155
|
// we make a copy of the child types of the struct here
|
|
157
156
|
auto child_types = StructType::GetChildTypes(type);
|
|
158
157
|
for (auto &child_type : child_types) {
|
|
159
158
|
child_type.second = ExchangeType(child_type.second, target, new_type);
|
|
160
159
|
}
|
|
161
|
-
return
|
|
162
|
-
: LogicalType::STRUCT(move(child_types));
|
|
160
|
+
return LogicalType::STRUCT(move(child_types));
|
|
163
161
|
}
|
|
164
162
|
case LogicalTypeId::UNION: {
|
|
165
163
|
auto member_types = UnionType::CopyMemberTypes(type);
|
|
@@ -170,6 +168,8 @@ LogicalType ExpressionBinder::ExchangeType(const LogicalType &type, LogicalTypeI
|
|
|
170
168
|
}
|
|
171
169
|
case LogicalTypeId::LIST:
|
|
172
170
|
return LogicalType::LIST(ExchangeType(ListType::GetChildType(type), target, new_type));
|
|
171
|
+
case LogicalTypeId::MAP:
|
|
172
|
+
return LogicalType::MAP(ExchangeType(ListType::GetChildType(type), target, new_type));
|
|
173
173
|
default:
|
|
174
174
|
return type;
|
|
175
175
|
}
|