duckdb 0.6.2-dev919.0 → 0.6.2-dev939.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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/extension/json/json_functions/json_create.cpp +6 -12
  3. package/src/duckdb/extension/parquet/column_writer.cpp +6 -5
  4. package/src/duckdb/extension/parquet/parquet_reader.cpp +6 -8
  5. package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -15
  6. package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -5
  7. package/src/duckdb/src/common/row_operations/row_gather.cpp +0 -1
  8. package/src/duckdb/src/common/row_operations/row_match.cpp +0 -1
  9. package/src/duckdb/src/common/row_operations/row_scatter.cpp +0 -2
  10. package/src/duckdb/src/common/sort/sort_state.cpp +0 -2
  11. package/src/duckdb/src/common/types/value.cpp +6 -8
  12. package/src/duckdb/src/common/types/vector.cpp +40 -43
  13. package/src/duckdb/src/common/types.cpp +20 -25
  14. package/src/duckdb/src/common/vector_operations/comparison_operators.cpp +0 -1
  15. package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +0 -2
  16. package/src/duckdb/src/common/vector_operations/vector_hash.cpp +0 -2
  17. package/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +0 -1
  18. package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +0 -1
  19. package/src/duckdb/src/function/aggregate/nested/histogram.cpp +7 -24
  20. package/src/duckdb/src/function/cast/list_casts.cpp +3 -3
  21. package/src/duckdb/src/function/cast/map_cast.cpp +19 -60
  22. package/src/duckdb/src/function/scalar/list/contains_or_position.cpp +0 -1
  23. package/src/duckdb/src/function/scalar/map/cardinality.cpp +1 -4
  24. package/src/duckdb/src/function/scalar/map/map.cpp +26 -38
  25. package/src/duckdb/src/function/scalar/map/map_extract.cpp +7 -6
  26. package/src/duckdb/src/function/scalar/map/map_from_entries.cpp +2 -117
  27. package/src/duckdb/src/function/table/arrow.cpp +6 -10
  28. package/src/duckdb/src/function/table/arrow_conversion.cpp +2 -55
  29. package/src/duckdb/src/function/table/system/test_all_types.cpp +14 -3
  30. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  31. package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -2
  32. package/src/duckdb/src/include/duckdb/common/types/vector.hpp +2 -2
  33. package/src/duckdb/src/include/duckdb/common/types.hpp +1 -3
  34. package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +4 -0
  35. package/src/duckdb/src/main/capi/logical_types-c.cpp +3 -2
  36. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +1 -8
  37. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +11 -9
  38. package/src/duckdb/src/planner/expression_binder.cpp +6 -6
  39. package/src/duckdb/src/storage/storage_info.cpp +1 -1
@@ -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 &parameters);
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 &ltype = *((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
- children.push_back({"key", LogicalType::LIST(key_type)});
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 = LogicalType::LIST(child_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 || type.id() == LogicalTypeId::MAP) {
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/Map Type
196
+ // Generate new Struct Type
191
197
  auto alias = type.GetAlias();
192
- if (type.id() == LogicalTypeId::STRUCT) {
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 type.id() == LogicalTypeId::MAP ? LogicalType::MAP(move(child_types))
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
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  namespace duckdb {
4
4
 
5
- const uint64_t VERSION_NUMBER = 40;
5
+ const uint64_t VERSION_NUMBER = 41;
6
6
 
7
7
  struct StorageVersionInfo {
8
8
  const char *version_name;