duckdb 0.8.2-dev3250.0 → 0.8.2-dev3300.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 (45) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/extension/parquet/column_reader.cpp +18 -4
  3. package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +1 -0
  4. package/src/duckdb/extension/parquet/include/parquet_writer.hpp +4 -0
  5. package/src/duckdb/extension/parquet/parquet_extension.cpp +3 -0
  6. package/src/duckdb/extension/parquet/parquet_statistics.cpp +18 -2
  7. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +6 -0
  8. package/src/duckdb/extension/parquet/parquet_writer.cpp +69 -15
  9. package/src/duckdb/src/common/enum_util.cpp +5 -0
  10. package/src/duckdb/src/common/operator/cast_operators.cpp +57 -0
  11. package/src/duckdb/src/common/operator/string_cast.cpp +45 -8
  12. package/src/duckdb/src/common/types/time.cpp +105 -0
  13. package/src/duckdb/src/common/types/value.cpp +7 -8
  14. package/src/duckdb/src/common/types/vector.cpp +1 -1
  15. package/src/duckdb/src/execution/column_binding_resolver.cpp +7 -0
  16. package/src/duckdb/src/execution/operator/schema/{physical_create_index.cpp → physical_create_art_index.cpp} +37 -46
  17. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +12 -4
  18. package/src/duckdb/src/function/cast/string_cast.cpp +2 -1
  19. package/src/duckdb/src/function/cast/time_casts.cpp +7 -6
  20. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  21. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -0
  22. package/src/duckdb/src/include/duckdb/common/enums/index_type.hpp +3 -2
  23. package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +22 -1
  24. package/src/duckdb/src/include/duckdb/common/operator/string_cast.hpp +1 -1
  25. package/src/duckdb/src/include/duckdb/common/types/datetime.hpp +46 -3
  26. package/src/duckdb/src/include/duckdb/common/types/time.hpp +5 -0
  27. package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -1
  28. package/src/duckdb/src/include/duckdb/execution/operator/schema/{physical_create_index.hpp → physical_create_art_index.hpp} +5 -5
  29. package/src/duckdb/src/include/duckdb/function/copy_function.hpp +6 -1
  30. package/src/duckdb/src/include/duckdb/function/udf_function.hpp +2 -1
  31. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +5 -0
  32. package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +3 -0
  33. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
  34. package/src/duckdb/src/main/appender.cpp +3 -1
  35. package/src/duckdb/src/main/capi/result-c.cpp +3 -1
  36. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +14 -0
  37. package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +27 -13
  38. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +29 -4
  39. package/src/duckdb/src/planner/operator/logical_extension_operator.cpp +15 -0
  40. package/src/duckdb/src/storage/index.cpp +3 -25
  41. package/src/duckdb/src/storage/local_storage.cpp +0 -1
  42. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +4 -0
  43. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  44. package/src/duckdb/ub_src_execution_operator_schema.cpp +1 -1
  45. package/test/test_all_types.test.ts +1 -1
@@ -1,4 +1,5 @@
1
1
  #include "duckdb/parser/expression/columnref_expression.hpp"
2
+ #include "duckdb/parser/expression/constant_expression.hpp"
2
3
  #include "duckdb/parser/statement/create_statement.hpp"
3
4
  #include "duckdb/parser/parsed_data/create_index_info.hpp"
4
5
  #include "duckdb/parser/tableref/basetableref.hpp"
@@ -7,18 +8,6 @@
7
8
 
8
9
  namespace duckdb {
9
10
 
10
- static IndexType StringToIndexType(const string &str) {
11
- string upper_str = StringUtil::Upper(str);
12
- if (upper_str == "INVALID") {
13
- return IndexType::INVALID;
14
- } else if (upper_str == "ART") {
15
- return IndexType::ART;
16
- } else {
17
- throw ConversionException("No IndexType conversion from string '%s'", upper_str);
18
- }
19
- return IndexType::INVALID;
20
- }
21
-
22
11
  vector<unique_ptr<ParsedExpression>> Transformer::TransformIndexParameters(duckdb_libpgquery::PGList &list,
23
12
  const string &relation_name) {
24
13
  vector<unique_ptr<ParsedExpression>> expressions;
@@ -56,7 +45,16 @@ unique_ptr<CreateStatement> Transformer::TransformCreateIndex(duckdb_libpgquery:
56
45
 
57
46
  info->expressions = TransformIndexParameters(*stmt.indexParams, stmt.relation->relname);
58
47
 
59
- info->index_type = StringToIndexType(string(stmt.accessMethod));
48
+ auto index_type_name = StringUtil::Upper(string(stmt.accessMethod));
49
+
50
+ if (index_type_name == "ART") {
51
+ info->index_type = IndexType::ART;
52
+ } else {
53
+ info->index_type = IndexType::EXTENSION;
54
+ }
55
+
56
+ info->index_type_name = index_type_name;
57
+
60
58
  if (stmt.relation->schemaname) {
61
59
  info->schema = stmt.relation->schemaname;
62
60
  }
@@ -69,6 +67,22 @@ unique_ptr<CreateStatement> Transformer::TransformCreateIndex(duckdb_libpgquery:
69
67
  } else {
70
68
  throw NotImplementedException("Index without a name not supported yet!");
71
69
  }
70
+
71
+ // Parse the options list
72
+ if (stmt.options) {
73
+ duckdb_libpgquery::PGListCell *cell;
74
+ for_each_cell(cell, stmt.options->head) {
75
+ auto def_elem = PGPointerCast<duckdb_libpgquery::PGDefElem>(cell->data.ptr_value);
76
+ Value val;
77
+ if (def_elem->arg) {
78
+ val = TransformValue(*PGPointerCast<duckdb_libpgquery::PGValue>(def_elem->arg))->value;
79
+ } else {
80
+ val = Value::BOOLEAN(true);
81
+ }
82
+ info->options[StringUtil::Lower(def_elem->defname)] = std::move(val);
83
+ }
84
+ }
85
+
72
86
  for (auto &expr : info->expressions) {
73
87
  info->parsed_expressions.emplace_back(expr->Copy());
74
88
  }
@@ -11,6 +11,9 @@
11
11
  #include "duckdb/planner/operator/logical_set_operation.hpp"
12
12
  #include "duckdb/parser/parsed_data/exported_table_data.hpp"
13
13
  #include "duckdb/parser/constraints/foreign_key_constraint.hpp"
14
+ #include "duckdb/parser/expression/cast_expression.hpp"
15
+ #include "duckdb/parser/tableref/basetableref.hpp"
16
+ #include "duckdb/parser/query_node/select_node.hpp"
14
17
 
15
18
  #include "duckdb/common/string_util.hpp"
16
19
  #include <algorithm>
@@ -96,6 +99,18 @@ string CreateFileName(const string &id_suffix, TableCatalogEntry &table, const s
96
99
  return StringUtil::Format("%s_%s%s.%s", schema, name, id_suffix, extension);
97
100
  }
98
101
 
102
+ unique_ptr<QueryNode> CreateSelectStatement(CopyStatement &stmt, vector<unique_ptr<ParsedExpression>> select_list) {
103
+ auto ref = make_uniq<BaseTableRef>();
104
+ ref->catalog_name = stmt.info->catalog;
105
+ ref->schema_name = stmt.info->schema;
106
+ ref->table_name = stmt.info->table;
107
+
108
+ auto statement = make_uniq<SelectNode>();
109
+ statement->from_table = std::move(ref);
110
+ statement->select_list = std::move(select_list);
111
+ return std::move(statement);
112
+ }
113
+
99
114
  BoundStatement Binder::Bind(ExportStatement &stmt) {
100
115
  // COPY TO a file
101
116
  auto &config = DBConfig::GetConfig(context);
@@ -163,7 +178,15 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
163
178
  info->table = table.name;
164
179
 
165
180
  // We can not export generated columns
181
+ vector<unique_ptr<ParsedExpression>> expressions;
166
182
  for (auto &col : table.GetColumns().Physical()) {
183
+ auto expression = make_uniq_base<ParsedExpression, ColumnRefExpression>(col.GetName());
184
+ auto is_supported = copy_function.function.supports_type;
185
+ if (is_supported && !is_supported(col.Type())) {
186
+ expression =
187
+ make_uniq_base<ParsedExpression, CastExpression>(LogicalType::VARCHAR, std::move(expression));
188
+ }
189
+ expressions.push_back(std::move(expression));
167
190
  info->select_list.push_back(col.GetName());
168
191
  }
169
192
 
@@ -181,17 +204,19 @@ BoundStatement Binder::Bind(ExportStatement &stmt) {
181
204
  // generate the copy statement and bind it
182
205
  CopyStatement copy_stmt;
183
206
  copy_stmt.info = std::move(info);
207
+ copy_stmt.select_statement = CreateSelectStatement(copy_stmt, std::move(expressions));
184
208
 
185
209
  auto copy_binder = Binder::CreateBinder(context, this);
186
210
  auto bound_statement = copy_binder->Bind(copy_stmt);
211
+ auto plan = std::move(bound_statement.plan);
212
+
187
213
  if (child_operator) {
188
214
  // use UNION ALL to combine the individual copy statements into a single node
189
- auto copy_union =
190
- make_uniq<LogicalSetOperation>(GenerateTableIndex(), 1, std::move(child_operator),
191
- std::move(bound_statement.plan), LogicalOperatorType::LOGICAL_UNION);
215
+ auto copy_union = make_uniq<LogicalSetOperation>(GenerateTableIndex(), 1, std::move(child_operator),
216
+ std::move(plan), LogicalOperatorType::LOGICAL_UNION);
192
217
  child_operator = std::move(copy_union);
193
218
  } else {
194
- child_operator = std::move(bound_statement.plan);
219
+ child_operator = std::move(plan);
195
220
  }
196
221
  }
197
222
 
@@ -1,4 +1,5 @@
1
1
  #include "duckdb/planner/operator/logical_extension_operator.hpp"
2
+ #include "duckdb/execution/column_binding_resolver.hpp"
2
3
  #include "duckdb/main/config.hpp"
3
4
  #include "duckdb/common/serializer/format_serializer.hpp"
4
5
  #include "duckdb/common/serializer/format_deserializer.hpp"
@@ -18,6 +19,20 @@ unique_ptr<LogicalExtensionOperator> LogicalExtensionOperator::Deserialize(Logic
18
19
  throw SerializationException("No serialization method exists for extension: " + extension_name);
19
20
  }
20
21
 
22
+ void LogicalExtensionOperator::ResolveColumnBindings(ColumnBindingResolver &res, vector<ColumnBinding> &bindings) {
23
+ // general case
24
+ // first visit the children of this operator
25
+ for (auto &child : children) {
26
+ res.VisitOperator(*child);
27
+ }
28
+ // now visit the expressions of this operator to resolve any bound column references
29
+ for (auto &expression : expressions) {
30
+ res.VisitExpression(&expression);
31
+ }
32
+ // finally update the current set of bindings to the current set of column bindings
33
+ bindings = GetColumnBindings();
34
+ }
35
+
21
36
  void LogicalExtensionOperator::FormatSerialize(FormatSerializer &serializer) const {
22
37
  LogicalOperator::FormatSerialize(serializer);
23
38
  serializer.WriteProperty(200, "extension_name", GetExtensionName());
@@ -4,7 +4,6 @@
4
4
  #include "duckdb/planner/expression/bound_columnref_expression.hpp"
5
5
  #include "duckdb/planner/expression/bound_reference_expression.hpp"
6
6
  #include "duckdb/storage/table/append_state.hpp"
7
- #include "duckdb/execution/index/art/art.hpp"
8
7
 
9
8
  namespace duckdb {
10
9
 
@@ -47,42 +46,21 @@ void Index::Delete(DataChunk &entries, Vector &row_identifiers) {
47
46
  }
48
47
 
49
48
  bool Index::MergeIndexes(Index &other_index) {
50
-
51
49
  IndexLock state;
52
50
  InitializeLock(state);
53
-
54
- switch (this->type) {
55
- case IndexType::ART:
56
- return Cast<ART>().MergeIndexes(state, other_index);
57
- default:
58
- throw InternalException("Unimplemented index type for merge");
59
- }
51
+ return MergeIndexes(state, other_index);
60
52
  }
61
53
 
62
54
  string Index::VerifyAndToString(const bool only_verify) {
63
-
64
55
  IndexLock state;
65
56
  InitializeLock(state);
66
-
67
- switch (this->type) {
68
- case IndexType::ART:
69
- return Cast<ART>().VerifyAndToString(state, only_verify);
70
- default:
71
- throw InternalException("Unimplemented index type for VerifyAndToString");
72
- }
57
+ return VerifyAndToString(state, only_verify);
73
58
  }
74
59
 
75
60
  void Index::Vacuum() {
76
-
77
61
  IndexLock state;
78
62
  InitializeLock(state);
79
-
80
- switch (this->type) {
81
- case IndexType::ART:
82
- return Cast<ART>().Vacuum(state);
83
- default:
84
- throw InternalException("Unimplemented index type for vacuum");
85
- }
63
+ Vacuum(state);
86
64
  }
87
65
 
88
66
  void Index::ExecuteExpressions(DataChunk &input, DataChunk &result) {
@@ -25,7 +25,6 @@ LocalTableStorage::LocalTableStorage(DataTable &table)
25
25
  table.info->indexes.Scan([&](Index &index) {
26
26
  D_ASSERT(index.type == IndexType::ART);
27
27
  auto &art = index.Cast<ART>();
28
- ;
29
28
  if (art.constraint_type != IndexConstraintType::NONE) {
30
29
  // unique index: create a local ART index that maintains the same unique constraint
31
30
  vector<unique_ptr<Expression>> unbound_expressions;
@@ -81,6 +81,8 @@ void CreateIndexInfo::FormatSerialize(FormatSerializer &serializer) const {
81
81
  serializer.WriteProperty(204, "parsed_expressions", parsed_expressions);
82
82
  serializer.WriteProperty(205, "names", names);
83
83
  serializer.WriteProperty(206, "column_ids", column_ids);
84
+ serializer.WriteProperty(207, "options", options);
85
+ serializer.WriteProperty(208, "index_type_name", index_type_name);
84
86
  }
85
87
 
86
88
  unique_ptr<CreateInfo> CreateIndexInfo::FormatDeserialize(FormatDeserializer &deserializer) {
@@ -92,6 +94,8 @@ unique_ptr<CreateInfo> CreateIndexInfo::FormatDeserialize(FormatDeserializer &de
92
94
  deserializer.ReadProperty(204, "parsed_expressions", result->parsed_expressions);
93
95
  deserializer.ReadProperty(205, "names", result->names);
94
96
  deserializer.ReadProperty(206, "column_ids", result->column_ids);
97
+ deserializer.ReadProperty(207, "options", result->options);
98
+ deserializer.ReadProperty(208, "index_type_name", result->index_type_name);
95
99
  return std::move(result);
96
100
  }
97
101
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  namespace duckdb {
4
4
 
5
- const uint64_t VERSION_NUMBER = 55;
5
+ const uint64_t VERSION_NUMBER = 56;
6
6
 
7
7
  struct StorageVersionInfo {
8
8
  const char *version_name;
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include "src/execution/operator/schema/physical_attach.cpp"
4
4
 
5
- #include "src/execution/operator/schema/physical_create_index.cpp"
5
+ #include "src/execution/operator/schema/physical_create_art_index.cpp"
6
6
 
7
7
  #include "src/execution/operator/schema/physical_create_schema.cpp"
8
8
 
@@ -159,7 +159,7 @@ const correct_answer_map: Record<string, any[]> = {
159
159
  map: ["{}", "{key1=🦆🦆🦆🦆🦆🦆, key2=goose}", null],
160
160
  union: ['Frank', '5', null],
161
161
 
162
- time_tz: ["00:00:00+00", "23:59:59.999999+00", null],
162
+ time_tz: ["00:00:00-1559", "23:59:59.999999+1559", null],
163
163
  interval: [
164
164
  timedelta({
165
165
  days: 0,