duckdb 0.8.2-dev2133.0 → 0.8.2-dev2278.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 (99) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/extension/json/json_functions.cpp +2 -1
  3. package/src/duckdb/extension/parquet/parquet_extension.cpp +2 -1
  4. package/src/duckdb/src/catalog/catalog.cpp +2 -6
  5. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +1 -4
  6. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +0 -4
  7. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +7 -26
  8. package/src/duckdb/src/catalog/catalog_set.cpp +0 -63
  9. package/src/duckdb/src/catalog/dependency_manager.cpp +0 -36
  10. package/src/duckdb/src/common/adbc/adbc.cpp +1 -1
  11. package/src/duckdb/src/common/extra_type_info.cpp +24 -46
  12. package/src/duckdb/src/common/field_writer.cpp +0 -1
  13. package/src/duckdb/src/common/file_system.cpp +6 -6
  14. package/src/duckdb/src/common/filename_pattern.cpp +1 -1
  15. package/src/duckdb/src/common/gzip_file_system.cpp +7 -12
  16. package/src/duckdb/src/common/multi_file_reader.cpp +8 -5
  17. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +0 -9
  18. package/src/duckdb/src/common/types.cpp +12 -56
  19. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  20. package/src/duckdb/src/core_functions/scalar/union/union_tag.cpp +1 -1
  21. package/src/duckdb/src/execution/column_binding_resolver.cpp +3 -7
  22. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +1 -1
  23. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +0 -10
  24. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +2 -1
  25. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -6
  26. package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +1 -2
  27. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +14 -1
  28. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +3 -17
  29. package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +2 -5
  30. package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -5
  31. package/src/duckdb/src/function/cast/string_cast.cpp +0 -1
  32. package/src/duckdb/src/function/scalar_function.cpp +3 -19
  33. package/src/duckdb/src/function/table/arrow.cpp +1 -1
  34. package/src/duckdb/src/function/table/arrow_conversion.cpp +12 -10
  35. package/src/duckdb/src/function/table/read_csv.cpp +2 -1
  36. package/src/duckdb/src/function/table/system/test_all_types.cpp +4 -4
  37. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  38. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +0 -2
  39. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -4
  40. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +0 -6
  41. package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +2 -6
  42. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +0 -4
  43. package/src/duckdb/src/include/duckdb/common/file_system.hpp +8 -8
  44. package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +1 -1
  45. package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +1 -1
  46. package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +4 -0
  47. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +0 -4
  48. package/src/duckdb/src/include/duckdb/common/serializer.hpp +0 -7
  49. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +14 -10
  50. package/src/duckdb/src/include/duckdb/common/types.hpp +5 -10
  51. package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +2 -0
  52. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +0 -4
  53. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -2
  54. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +0 -3
  55. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +1 -1
  56. package/src/duckdb/src/include/duckdb/optimizer/deliminator.hpp +2 -2
  57. package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +0 -2
  58. package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +1 -2
  59. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +2 -4
  60. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +10 -7
  61. package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +5 -0
  62. package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +1 -0
  63. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +0 -3
  64. package/src/duckdb/src/include/duckdb.h +15 -0
  65. package/src/duckdb/src/main/attached_database.cpp +2 -2
  66. package/src/duckdb/src/main/capi/duckdb-c.cpp +16 -0
  67. package/src/duckdb/src/main/database.cpp +1 -1
  68. package/src/duckdb/src/main/db_instance_cache.cpp +14 -6
  69. package/src/duckdb/src/main/extension/extension_install.cpp +1 -1
  70. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +1 -2
  71. package/src/duckdb/src/optimizer/compressed_materialization.cpp +0 -1
  72. package/src/duckdb/src/optimizer/deliminator.cpp +7 -7
  73. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +3 -5
  74. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +16 -1
  75. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +1 -1
  76. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +3 -3
  77. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +8 -23
  78. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +0 -24
  79. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +3 -5
  80. package/src/duckdb/src/planner/logical_operator.cpp +1 -6
  81. package/src/duckdb/src/planner/logical_operator_visitor.cpp +3 -6
  82. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +2 -14
  83. package/src/duckdb/src/planner/operator/logical_create_index.cpp +21 -12
  84. package/src/duckdb/src/planner/operator/logical_extension_operator.cpp +24 -0
  85. package/src/duckdb/src/planner/planner.cpp +0 -1
  86. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -5
  87. package/src/duckdb/src/storage/meta_block_reader.cpp +0 -9
  88. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +2 -0
  89. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +27 -0
  90. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  91. package/src/duckdb/src/storage/table/list_column_data.cpp +6 -3
  92. package/src/duckdb/src/storage/wal_replay.cpp +1 -3
  93. package/src/duckdb/ub_src_planner_operator.cpp +0 -4
  94. package/src/statement.cpp +0 -2
  95. package/test/columns.test.ts +1 -2
  96. package/src/duckdb/src/include/duckdb/planner/operator/logical_asof_join.hpp +0 -27
  97. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_join.hpp +0 -32
  98. package/src/duckdb/src/planner/operator/logical_asof_join.cpp +0 -14
  99. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +0 -25
@@ -26,7 +26,7 @@ struct timestamp_t { // NOLINT
26
26
  int64_t value;
27
27
 
28
28
  timestamp_t() = default;
29
- explicit inline timestamp_t(int64_t value_p) : value(value_p) {
29
+ explicit inline constexpr timestamp_t(int64_t value_p) : value(value_p) {
30
30
  }
31
31
  inline timestamp_t &operator=(int64_t value_p) {
32
32
  value = value_p;
@@ -67,21 +67,25 @@ struct timestamp_t { // NOLINT
67
67
  timestamp_t &operator-=(const int64_t &delta);
68
68
 
69
69
  // special values
70
- static timestamp_t infinity() { // NOLINT
70
+ static constexpr timestamp_t infinity() { // NOLINT
71
71
  return timestamp_t(NumericLimits<int64_t>::Maximum());
72
- } // NOLINT
73
- static timestamp_t ninfinity() { // NOLINT
72
+ } // NOLINT
73
+ static constexpr timestamp_t ninfinity() { // NOLINT
74
74
  return timestamp_t(-NumericLimits<int64_t>::Maximum());
75
- } // NOLINT
76
- static inline timestamp_t epoch() { // NOLINT
75
+ } // NOLINT
76
+ static constexpr inline timestamp_t epoch() { // NOLINT
77
77
  return timestamp_t(0);
78
78
  } // NOLINT
79
79
  };
80
80
 
81
- struct timestamp_tz_t : public timestamp_t {}; // NOLINT
82
- struct timestamp_ns_t : public timestamp_t {}; // NOLINT
83
- struct timestamp_ms_t : public timestamp_t {}; // NOLINT
84
- struct timestamp_sec_t : public timestamp_t {}; // NOLINT
81
+ struct timestamp_tz_t : public timestamp_t { // NOLINT
82
+ };
83
+ struct timestamp_ns_t : public timestamp_t { // NOLINT
84
+ };
85
+ struct timestamp_ms_t : public timestamp_t { // NOLINT
86
+ };
87
+ struct timestamp_sec_t : public timestamp_t { // NOLINT
88
+ };
85
89
 
86
90
  enum class TimestampCastResult : uint8_t { SUCCESS, ERROR_INCORRECT_FORMAT, ERROR_NON_UTC_TIMEZONE };
87
91
 
@@ -286,8 +286,6 @@ struct LogicalType {
286
286
  //! Serializes a LogicalType to a stand-alone binary blob
287
287
  DUCKDB_API void Serialize(Serializer &serializer) const;
288
288
 
289
- DUCKDB_API void SerializeEnumType(Serializer &serializer) const;
290
-
291
289
  //! Deserializes a blob back into an LogicalType
292
290
  DUCKDB_API static LogicalType Deserialize(Deserializer &source);
293
291
 
@@ -373,9 +371,10 @@ public:
373
371
  DUCKDB_API static LogicalType STRUCT(child_list_t<LogicalType> children); // NOLINT
374
372
  DUCKDB_API static LogicalType AGGREGATE_STATE(aggregate_state_t state_type); // NOLINT
375
373
  DUCKDB_API static LogicalType MAP(const LogicalType &child); // NOLINT
376
- DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
377
374
  DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
378
375
  DUCKDB_API static LogicalType UNION( child_list_t<LogicalType> members); // NOLINT
376
+ DUCKDB_API static LogicalType ENUM(Vector &ordered_data, idx_t size); // NOLINT
377
+ // DEPRECATED - provided for backwards compatibility
379
378
  DUCKDB_API static LogicalType ENUM(const string &enum_name, Vector &ordered_data, idx_t size); // NOLINT
380
379
  DUCKDB_API static LogicalType USER(const string &user_type_name); // NOLINT
381
380
  //! A list of all NUMERIC types (integral and floating point types)
@@ -400,21 +399,17 @@ struct ListType {
400
399
  DUCKDB_API static const LogicalType &GetChildType(const LogicalType &type);
401
400
  };
402
401
 
403
- struct UserType{
402
+ struct UserType {
404
403
  DUCKDB_API static const string &GetTypeName(const LogicalType &type);
405
404
  };
406
405
 
407
- struct EnumType{
408
- DUCKDB_API static const string &GetTypeName(const LogicalType &type);
406
+ struct EnumType {
409
407
  DUCKDB_API static int64_t GetPos(const LogicalType &type, const string_t& key);
410
408
  DUCKDB_API static const Vector &GetValuesInsertOrder(const LogicalType &type);
411
409
  DUCKDB_API static idx_t GetSize(const LogicalType &type);
412
410
  DUCKDB_API static const string GetValue(const Value &val);
413
- DUCKDB_API static void SetCatalog(LogicalType &type, optional_ptr<TypeCatalogEntry> catalog_entry);
414
- DUCKDB_API static optional_ptr<TypeCatalogEntry> GetCatalog(const LogicalType &type);
415
- DUCKDB_API static string GetSchemaName(const LogicalType &type);
416
411
  DUCKDB_API static PhysicalType GetPhysicalType(const LogicalType &type);
417
- DUCKDB_API static void Serialize(FieldWriter& writer, const ExtraTypeInfo& type_info, bool serialize_internals);
412
+ DUCKDB_API static string_t GetString(const LogicalType &type, idx_t pos);
418
413
  };
419
414
 
420
415
  struct StructType {
@@ -68,6 +68,8 @@ public:
68
68
 
69
69
  void SetDisabledFileSystems(const vector<string> &names) override;
70
70
 
71
+ string PathSeparator(const string &path) override;
72
+
71
73
  private:
72
74
  FileSystem &FindFileSystem(const string &path);
73
75
  FileSystem &FindFileSystemInternal(const string &path);
@@ -22,10 +22,6 @@ public:
22
22
  static constexpr const PhysicalOperatorType TYPE = PhysicalOperatorType::TABLE_SCAN;
23
23
 
24
24
  public:
25
- //! Regular Table Scan
26
- PhysicalTableScan(vector<LogicalType> types, TableFunction function, unique_ptr<FunctionData> bind_data,
27
- vector<column_t> column_ids, vector<string> names, unique_ptr<TableFilterSet> table_filters,
28
- idx_t estimated_cardinality);
29
25
  //! Table scan that immediately projects out filter columns that are unused in the remainder of the query plan
30
26
  PhysicalTableScan(vector<LogicalType> types, TableFunction function, unique_ptr<FunctionData> bind_data,
31
27
  vector<LogicalType> returned_types, vector<column_t> column_ids, vector<idx_t> projection_ids,
@@ -50,7 +50,6 @@ protected:
50
50
 
51
51
  unique_ptr<PhysicalOperator> CreatePlan(LogicalAggregate &op);
52
52
  unique_ptr<PhysicalOperator> CreatePlan(LogicalAnyJoin &op);
53
- unique_ptr<PhysicalOperator> CreatePlan(LogicalAsOfJoin &op);
54
53
  unique_ptr<PhysicalOperator> CreatePlan(LogicalColumnDataGet &op);
55
54
  unique_ptr<PhysicalOperator> CreatePlan(LogicalComparisonJoin &op);
56
55
  unique_ptr<PhysicalOperator> CreatePlan(LogicalCreate &op);
@@ -59,7 +58,6 @@ protected:
59
58
  unique_ptr<PhysicalOperator> CreatePlan(LogicalCrossProduct &op);
60
59
  unique_ptr<PhysicalOperator> CreatePlan(LogicalDelete &op);
61
60
  unique_ptr<PhysicalOperator> CreatePlan(LogicalDelimGet &op);
62
- unique_ptr<PhysicalOperator> CreatePlan(LogicalDelimJoin &op);
63
61
  unique_ptr<PhysicalOperator> CreatePlan(LogicalDistinct &op);
64
62
  unique_ptr<PhysicalOperator> CreatePlan(LogicalDummyScan &expr);
65
63
  unique_ptr<PhysicalOperator> CreatePlan(LogicalEmptyResult &op);
@@ -93,6 +91,9 @@ protected:
93
91
  unique_ptr<PhysicalOperator> CreatePlan(LogicalCTERef &op);
94
92
  unique_ptr<PhysicalOperator> CreatePlan(LogicalPivot &op);
95
93
 
94
+ unique_ptr<PhysicalOperator> PlanAsOfJoin(LogicalComparisonJoin &op);
95
+ unique_ptr<PhysicalOperator> PlanComparisonJoin(LogicalComparisonJoin &op);
96
+ unique_ptr<PhysicalOperator> PlanDelimJoin(LogicalComparisonJoin &op);
96
97
  unique_ptr<PhysicalOperator> ExtractAggregateExpressions(unique_ptr<PhysicalOperator> child,
97
98
  vector<unique_ptr<Expression>> &expressions,
98
99
  vector<unique_ptr<Expression>> &groups);
@@ -113,9 +113,6 @@ public:
113
113
 
114
114
  DUCKDB_API bool Equal(const ScalarFunction &rhs) const;
115
115
 
116
- private:
117
- bool CompareScalarFunctionT(const scalar_function_t &other) const;
118
-
119
116
  public:
120
117
  DUCKDB_API static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result);
121
118
 
@@ -60,7 +60,7 @@ public:
60
60
  bool IsInitialDatabase() const;
61
61
  void SetInitialDatabase();
62
62
 
63
- static string ExtractDatabaseName(const string &dbpath);
63
+ static string ExtractDatabaseName(const string &dbpath, FileSystem &fs);
64
64
 
65
65
  private:
66
66
  DatabaseInstance &db;
@@ -27,9 +27,9 @@ private:
27
27
  void FindCandidates(unique_ptr<LogicalOperator> &op, vector<DelimCandidate> &candidates);
28
28
  void FindJoinWithDelimGet(unique_ptr<LogicalOperator> &op, DelimCandidate &candidate);
29
29
  //! Remove joins with a DelimGet
30
- bool RemoveJoinWithDelimGet(LogicalDelimJoin &delim_join, const idx_t delim_get_count,
30
+ bool RemoveJoinWithDelimGet(LogicalComparisonJoin &delim_join, const idx_t delim_get_count,
31
31
  unique_ptr<LogicalOperator> &join, bool &all_equality_conditions);
32
- bool RemoveInequalityJoinWithDelimGet(LogicalDelimJoin &delim_join, const idx_t delim_get_count,
32
+ bool RemoveInequalityJoinWithDelimGet(LogicalComparisonJoin &delim_join, const idx_t delim_get_count,
33
33
  unique_ptr<LogicalOperator> &join,
34
34
  const vector<ReplacementBinding> &replacement_bindings);
35
35
 
@@ -14,7 +14,6 @@ class LogicalOperator;
14
14
 
15
15
  class LogicalAggregate;
16
16
  class LogicalAnyJoin;
17
- class LogicalAsOfJoin;
18
17
  class LogicalColumnDataGet;
19
18
  class LogicalComparisonJoin;
20
19
  class LogicalCopyToFile;
@@ -26,7 +25,6 @@ class LogicalCrossProduct;
26
25
  class LogicalCTERef;
27
26
  class LogicalDelete;
28
27
  class LogicalDelimGet;
29
- class LogicalDelimJoin;
30
28
  class LogicalDistinct;
31
29
  class LogicalDummyScan;
32
30
  class LogicalEmptyResult;
@@ -1,6 +1,5 @@
1
1
  #include "duckdb/planner/operator/logical_aggregate.hpp"
2
2
  #include "duckdb/planner/operator/logical_any_join.hpp"
3
- #include "duckdb/planner/operator/logical_asof_join.hpp"
4
3
  #include "duckdb/planner/operator/logical_column_data_get.hpp"
5
4
  #include "duckdb/planner/operator/logical_comparison_join.hpp"
6
5
  #include "duckdb/planner/operator/logical_copy_to_file.hpp"
@@ -11,7 +10,6 @@
11
10
  #include "duckdb/planner/operator/logical_cteref.hpp"
12
11
  #include "duckdb/planner/operator/logical_delete.hpp"
13
12
  #include "duckdb/planner/operator/logical_delim_get.hpp"
14
- #include "duckdb/planner/operator/logical_delim_join.hpp"
15
13
  #include "duckdb/planner/operator/logical_distinct.hpp"
16
14
  #include "duckdb/planner/operator/logical_dummy_scan.hpp"
17
15
  #include "duckdb/planner/operator/logical_empty_result.hpp"
@@ -19,6 +17,7 @@
19
17
  #include "duckdb/planner/operator/logical_explain.hpp"
20
18
  #include "duckdb/planner/operator/logical_export.hpp"
21
19
  #include "duckdb/planner/operator/logical_expression_get.hpp"
20
+ #include "duckdb/planner/operator/logical_extension_operator.hpp"
22
21
  #include "duckdb/planner/operator/logical_filter.hpp"
23
22
  #include "duckdb/planner/operator/logical_get.hpp"
24
23
  #include "duckdb/planner/operator/logical_insert.hpp"
@@ -15,7 +15,6 @@
15
15
  #include "duckdb/planner/operator/logical_join.hpp"
16
16
 
17
17
  namespace duckdb {
18
- class LogicalDelimJoin;
19
18
 
20
19
  //! LogicalComparisonJoin represents a join that involves comparisons between the LHS and RHS
21
20
  class LogicalComparisonJoin : public LogicalJoin {
@@ -30,6 +29,8 @@ public:
30
29
  vector<JoinCondition> conditions;
31
30
  //! Used for duplicate-eliminated MARK joins
32
31
  vector<LogicalType> mark_types;
32
+ //! The set of columns that will be duplicate eliminated from the LHS and pushed into the RHS
33
+ vector<unique_ptr<Expression>> duplicate_eliminated_columns;
33
34
 
34
35
  public:
35
36
  string ParamsToString() const override;
@@ -41,9 +42,6 @@ public:
41
42
  void FormatSerialize(FormatSerializer &serializer) const override;
42
43
  static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
43
44
 
44
- //! Turn a delim join into a regular comparison join (after all required delim scans have been pruned)
45
- static unique_ptr<LogicalOperator> FromDelimJoin(LogicalDelimJoin &join);
46
-
47
45
  public:
48
46
  static unique_ptr<LogicalOperator> CreateJoin(ClientContext &context, JoinType type, JoinRefType ref_type,
49
47
  unique_ptr<LogicalOperator> left_child,
@@ -19,19 +19,14 @@ public:
19
19
  static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_CREATE_INDEX;
20
20
 
21
21
  public:
22
- LogicalCreateIndex(unique_ptr<FunctionData> bind_data_p, unique_ptr<CreateIndexInfo> info_p,
23
- vector<unique_ptr<Expression>> expressions_p, TableCatalogEntry &table_p,
24
- TableFunction function_p);
22
+ LogicalCreateIndex(unique_ptr<CreateIndexInfo> info_p, vector<unique_ptr<Expression>> expressions_p,
23
+ TableCatalogEntry &table_p);
25
24
 
26
- //! The bind data of the function
27
- unique_ptr<FunctionData> bind_data;
28
25
  // Info for index creation
29
26
  unique_ptr<CreateIndexInfo> info;
30
27
 
31
28
  //! The table to create the index for
32
29
  TableCatalogEntry &table;
33
- //! The function that is called
34
- TableFunction function;
35
30
 
36
31
  //! Unbound expressions to be used in the optimizer
37
32
  vector<unique_ptr<Expression>> unbound_expressions;
@@ -40,7 +35,15 @@ public:
40
35
  void Serialize(FieldWriter &writer) const override;
41
36
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
42
37
 
38
+ void FormatSerialize(FormatSerializer &serializer) const override;
39
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
40
+
43
41
  protected:
44
42
  void ResolveTypes() override;
43
+
44
+ private:
45
+ LogicalCreateIndex(ClientContext &context, unique_ptr<CreateInfo> info, vector<unique_ptr<Expression>> expressions);
46
+
47
+ TableCatalogEntry &BindTable(ClientContext &context, CreateIndexInfo &info);
45
48
  };
46
49
  } // namespace duckdb
@@ -26,6 +26,11 @@ public:
26
26
 
27
27
  static unique_ptr<LogicalExtensionOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
28
28
 
29
+ virtual void FormatSerialize(FormatSerializer &serializer) const override;
30
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
31
+
29
32
  virtual unique_ptr<PhysicalOperator> CreatePlan(ClientContext &context, PhysicalPlanGenerator &generator) = 0;
33
+
34
+ virtual string GetExtensionName() const;
30
35
  };
31
36
  } // namespace duckdb
@@ -36,6 +36,7 @@ public:
36
36
  virtual std::string GetName() = 0;
37
37
  virtual unique_ptr<LogicalExtensionOperator> Deserialize(LogicalDeserializationState &state,
38
38
  FieldReader &reader) = 0;
39
+ virtual unique_ptr<LogicalExtensionOperator> FormatDeserialize(FormatDeserializer &deserializer) = 0;
39
40
 
40
41
  virtual ~OperatorExtension() {
41
42
  }
@@ -37,13 +37,10 @@ public:
37
37
  void ReadData(data_ptr_t buffer, idx_t read_size) override;
38
38
 
39
39
  ClientContext &GetContext() override;
40
- optional_ptr<Catalog> GetCatalog() override;
41
- void SetCatalog(Catalog &catalog_p);
42
40
  void SetContext(ClientContext &context_p);
43
41
 
44
42
  private:
45
43
  void ReadNewBlock(block_id_t id);
46
44
  optional_ptr<ClientContext> context;
47
- optional_ptr<Catalog> catalog;
48
45
  };
49
46
  } // namespace duckdb
@@ -360,6 +360,21 @@ The instantiated connection should be closed using 'duckdb_disconnect'
360
360
  */
361
361
  DUCKDB_API duckdb_state duckdb_connect(duckdb_database database, duckdb_connection *out_connection);
362
362
 
363
+ /*!
364
+ Interrupt running query
365
+
366
+ * connection: The connection to interruot
367
+ */
368
+ DUCKDB_API void duckdb_interrupt(duckdb_connection connection);
369
+
370
+ /*!
371
+ Get progress of the running query
372
+
373
+ * connection: The working connection
374
+ * returns: -1 if no progress or a percentage of the progress
375
+ */
376
+ DUCKDB_API double duckdb_query_progress(duckdb_connection connection);
377
+
363
378
  /*!
364
379
  Closes the specified connection and de-allocates all memory allocated for that connection.
365
380
 
@@ -87,11 +87,11 @@ bool AttachedDatabase::IsReadOnly() const {
87
87
  return type == AttachedDatabaseType::READ_ONLY_DATABASE;
88
88
  }
89
89
 
90
- string AttachedDatabase::ExtractDatabaseName(const string &dbpath) {
90
+ string AttachedDatabase::ExtractDatabaseName(const string &dbpath, FileSystem &fs) {
91
91
  if (dbpath.empty() || dbpath == ":memory:") {
92
92
  return "memory";
93
93
  }
94
- return FileSystem::ExtractBaseName(dbpath);
94
+ return fs.ExtractBaseName(dbpath);
95
95
  }
96
96
 
97
97
  void AttachedDatabase::Initialize() {
@@ -54,6 +54,22 @@ duckdb_state duckdb_connect(duckdb_database database, duckdb_connection *out) {
54
54
  return DuckDBSuccess;
55
55
  }
56
56
 
57
+ void duckdb_interrupt(duckdb_connection connection) {
58
+ if (!connection) {
59
+ return;
60
+ }
61
+ Connection *conn = reinterpret_cast<Connection *>(connection);
62
+ conn->Interrupt();
63
+ }
64
+
65
+ double duckdb_query_progress(duckdb_connection connection) {
66
+ if (!connection) {
67
+ return -1;
68
+ }
69
+ Connection *conn = reinterpret_cast<Connection *>(connection);
70
+ return conn->context->GetProgress();
71
+ }
72
+
57
73
  void duckdb_disconnect(duckdb_connection *connection) {
58
74
  if (connection && *connection) {
59
75
  Connection *conn = reinterpret_cast<Connection *>(*connection);
@@ -158,7 +158,7 @@ duckdb::unique_ptr<AttachedDatabase> DatabaseInstance::CreateAttachedDatabase(At
158
158
 
159
159
  void DatabaseInstance::CreateMainDatabase() {
160
160
  AttachInfo info;
161
- info.name = AttachedDatabase::ExtractDatabaseName(config.options.database_path);
161
+ info.name = AttachedDatabase::ExtractDatabaseName(config.options.database_path, GetFileSystem());
162
162
  info.path = config.options.database_path;
163
163
 
164
164
  auto attached_database = CreateAttachedDatabase(info, config.options.database_type, config.options.access_mode);
@@ -3,7 +3,7 @@
3
3
 
4
4
  namespace duckdb {
5
5
 
6
- string GetDBAbsolutePath(const string &database_p) {
6
+ string GetDBAbsolutePath(const string &database_p, FileSystem &fs) {
7
7
  auto database = FileSystem::ExpandPath(database_p, nullptr);
8
8
  if (database.empty()) {
9
9
  return ":memory:";
@@ -16,15 +16,17 @@ string GetDBAbsolutePath(const string &database_p) {
16
16
  // this database path is handled by a replacement open and is not a file path
17
17
  return database;
18
18
  }
19
- if (FileSystem::IsPathAbsolute(database)) {
20
- return FileSystem::NormalizeAbsolutePath(database);
19
+ if (fs.IsPathAbsolute(database)) {
20
+ return fs.NormalizeAbsolutePath(database);
21
21
  }
22
- return FileSystem::NormalizeAbsolutePath(FileSystem::JoinPath(FileSystem::GetWorkingDirectory(), database));
22
+ return fs.NormalizeAbsolutePath(fs.JoinPath(FileSystem::GetWorkingDirectory(), database));
23
23
  }
24
24
 
25
25
  shared_ptr<DuckDB> DBInstanceCache::GetInstanceInternal(const string &database, const DBConfig &config) {
26
26
  shared_ptr<DuckDB> db_instance;
27
- auto abs_database_path = GetDBAbsolutePath(database);
27
+
28
+ auto local_fs = FileSystem::CreateLocal();
29
+ auto abs_database_path = GetDBAbsolutePath(database, *local_fs);
28
30
  if (db_instances.find(abs_database_path) != db_instances.end()) {
29
31
  db_instance = db_instances[abs_database_path].lock();
30
32
  if (db_instance) {
@@ -48,7 +50,13 @@ shared_ptr<DuckDB> DBInstanceCache::GetInstance(const string &database, const DB
48
50
 
49
51
  shared_ptr<DuckDB> DBInstanceCache::CreateInstanceInternal(const string &database, DBConfig &config,
50
52
  bool cache_instance) {
51
- auto abs_database_path = GetDBAbsolutePath(database);
53
+ string abs_database_path;
54
+ if (config.file_system) {
55
+ abs_database_path = GetDBAbsolutePath(database, *config.file_system);
56
+ } else {
57
+ auto tmp_fs = FileSystem::CreateLocal();
58
+ abs_database_path = GetDBAbsolutePath(database, *tmp_fs);
59
+ }
52
60
  if (db_instances.find(abs_database_path) != db_instances.end()) {
53
61
  throw duckdb::Exception(ExceptionType::CONNECTION,
54
62
  "Instance with path: " + abs_database_path + " already exists.");
@@ -56,7 +56,7 @@ string ExtensionHelper::ExtensionDirectory(DBConfig &config, FileSystem &fs) {
56
56
  // expand ~ in extension directory
57
57
  extension_directory = fs.ExpandPath(extension_directory);
58
58
  if (!fs.DirectoryExists(extension_directory)) {
59
- auto sep = fs.PathSeparator();
59
+ auto sep = fs.PathSeparator(extension_directory);
60
60
  auto splits = StringUtil::Split(extension_directory, sep);
61
61
  D_ASSERT(!splits.empty());
62
62
  string extension_directory_prefix;
@@ -1,7 +1,6 @@
1
1
  #include "duckdb/optimizer/column_lifetime_optimizer.hpp"
2
2
  #include "duckdb/planner/expression/bound_columnref_expression.hpp"
3
3
  #include "duckdb/planner/operator/logical_comparison_join.hpp"
4
- #include "duckdb/planner/operator/logical_delim_join.hpp"
5
4
  #include "duckdb/planner/operator/logical_filter.hpp"
6
5
 
7
6
  namespace duckdb {
@@ -38,7 +37,7 @@ void ColumnLifetimeAnalyzer::StandardVisitOperator(LogicalOperator &op) {
38
37
  LogicalOperatorVisitor::VisitOperatorExpressions(op);
39
38
  if (op.type == LogicalOperatorType::LOGICAL_DELIM_JOIN) {
40
39
  // visit the duplicate eliminated columns on the LHS, if any
41
- auto &delim_join = op.Cast<LogicalDelimJoin>();
40
+ auto &delim_join = op.Cast<LogicalComparisonJoin>();
42
41
  for (auto &expr : delim_join.duplicate_eliminated_columns) {
43
42
  VisitExpression(&expr);
44
43
  }
@@ -9,7 +9,6 @@
9
9
  #include "duckdb/planner/expression/bound_function_expression.hpp"
10
10
  #include "duckdb/planner/expression_iterator.hpp"
11
11
  #include "duckdb/planner/operator/logical_comparison_join.hpp"
12
- #include "duckdb/planner/operator/logical_delim_join.hpp"
13
12
  #include "duckdb/planner/operator/logical_projection.hpp"
14
13
 
15
14
  namespace duckdb {
@@ -7,21 +7,21 @@
7
7
  #include "duckdb/planner/expression/bound_conjunction_expression.hpp"
8
8
  #include "duckdb/planner/expression/bound_operator_expression.hpp"
9
9
  #include "duckdb/planner/operator/logical_aggregate.hpp"
10
+ #include "duckdb/planner/operator/logical_comparison_join.hpp"
10
11
  #include "duckdb/planner/operator/logical_delim_get.hpp"
11
- #include "duckdb/planner/operator/logical_delim_join.hpp"
12
12
  #include "duckdb/planner/operator/logical_filter.hpp"
13
13
 
14
14
  namespace duckdb {
15
15
 
16
16
  struct DelimCandidate {
17
17
  public:
18
- explicit DelimCandidate(unique_ptr<LogicalOperator> &op, LogicalDelimJoin &delim_join)
18
+ explicit DelimCandidate(unique_ptr<LogicalOperator> &op, LogicalComparisonJoin &delim_join)
19
19
  : op(op), delim_join(delim_join), delim_get_count(0) {
20
20
  }
21
21
 
22
22
  public:
23
23
  unique_ptr<LogicalOperator> &op;
24
- LogicalDelimJoin &delim_join;
24
+ LogicalComparisonJoin &delim_join;
25
25
  vector<reference<unique_ptr<LogicalOperator>>> joins;
26
26
  idx_t delim_get_count;
27
27
  };
@@ -55,6 +55,7 @@ unique_ptr<LogicalOperator> Deliminator::Optimize(unique_ptr<LogicalOperator> op
55
55
 
56
56
  // Change type if there are no more duplicate-eliminated columns
57
57
  if (candidate.joins.size() == candidate.delim_get_count && all_removed) {
58
+ delim_join.type = LogicalOperatorType::LOGICAL_COMPARISON_JOIN;
58
59
  delim_join.duplicate_eliminated_columns.clear();
59
60
  if (all_equality_conditions) {
60
61
  for (auto &cond : delim_join.conditions) {
@@ -63,7 +64,6 @@ unique_ptr<LogicalOperator> Deliminator::Optimize(unique_ptr<LogicalOperator> op
63
64
  }
64
65
  }
65
66
  }
66
- candidate.op = LogicalComparisonJoin::FromDelimJoin(delim_join);
67
67
  }
68
68
  }
69
69
 
@@ -80,7 +80,7 @@ void Deliminator::FindCandidates(unique_ptr<LogicalOperator> &op, vector<DelimCa
80
80
  return;
81
81
  }
82
82
 
83
- candidates.emplace_back(op, op->Cast<LogicalDelimJoin>());
83
+ candidates.emplace_back(op, op->Cast<LogicalComparisonJoin>());
84
84
  auto &candidate = candidates.back();
85
85
 
86
86
  // DelimGets are in the RHS
@@ -125,7 +125,7 @@ static bool ChildJoinTypeCanBeDeliminated(JoinType &join_type) {
125
125
  }
126
126
  }
127
127
 
128
- bool Deliminator::RemoveJoinWithDelimGet(LogicalDelimJoin &delim_join, const idx_t delim_get_count,
128
+ bool Deliminator::RemoveJoinWithDelimGet(LogicalComparisonJoin &delim_join, const idx_t delim_get_count,
129
129
  unique_ptr<LogicalOperator> &join, bool &all_equality_conditions) {
130
130
  auto &comparison_join = join->Cast<LogicalComparisonJoin>();
131
131
  if (!ChildJoinTypeCanBeDeliminated(comparison_join.join_type)) {
@@ -218,7 +218,7 @@ bool FindAndReplaceBindings(vector<ColumnBinding> &traced_bindings, const vector
218
218
  return true;
219
219
  }
220
220
 
221
- bool Deliminator::RemoveInequalityJoinWithDelimGet(LogicalDelimJoin &delim_join, const idx_t delim_get_count,
221
+ bool Deliminator::RemoveInequalityJoinWithDelimGet(LogicalComparisonJoin &delim_join, const idx_t delim_get_count,
222
222
  unique_ptr<LogicalOperator> &join,
223
223
  const vector<ReplacementBinding> &replacement_bindings) {
224
224
  auto &comparison_join = join->Cast<LogicalComparisonJoin>();
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include "duckdb/common/pair.hpp"
4
4
  #include "duckdb/planner/operator/logical_delim_get.hpp"
5
- #include "duckdb/planner/operator/logical_delim_join.hpp"
5
+ #include "duckdb/planner/operator/logical_comparison_join.hpp"
6
6
  #include "duckdb/planner/operator/logical_unnest.hpp"
7
7
  #include "duckdb/planner/operator/logical_projection.hpp"
8
8
  #include "duckdb/planner/operator/logical_window.hpp"
@@ -17,11 +17,9 @@ void UnnestRewriterPlanUpdater::VisitOperator(LogicalOperator &op) {
17
17
  }
18
18
 
19
19
  void UnnestRewriterPlanUpdater::VisitExpression(unique_ptr<Expression> *expression) {
20
-
21
20
  auto &expr = *expression;
22
21
 
23
22
  if (expr->expression_class == ExpressionClass::BOUND_COLUMN_REF) {
24
-
25
23
  auto &bound_column_ref = expr->Cast<BoundColumnRefExpression>();
26
24
  for (idx_t i = 0; i < replace_bindings.size(); i++) {
27
25
  if (bound_column_ref.binding == replace_bindings[i].old_binding) {
@@ -76,7 +74,7 @@ void UnnestRewriter::FindCandidates(unique_ptr<LogicalOperator> *op_ptr,
76
74
  }
77
75
 
78
76
  // found a delim join
79
- auto &delim_join = op->children[0]->Cast<LogicalDelimJoin>();
77
+ auto &delim_join = op->children[0]->Cast<LogicalComparisonJoin>();
80
78
  // only support INNER delim joins
81
79
  if (delim_join.join_type != JoinType::INNER) {
82
80
  return;
@@ -295,7 +293,7 @@ void UnnestRewriter::UpdateBoundUnnestBindings(UnnestRewriterPlanUpdater &update
295
293
  void UnnestRewriter::GetDelimColumns(LogicalOperator &op) {
296
294
 
297
295
  D_ASSERT(op.type == LogicalOperatorType::LOGICAL_DELIM_JOIN);
298
- auto &delim_join = op.Cast<LogicalDelimJoin>();
296
+ auto &delim_join = op.Cast<LogicalComparisonJoin>();
299
297
  for (idx_t i = 0; i < delim_join.duplicate_eliminated_columns.size(); i++) {
300
298
  auto &expr = *delim_join.duplicate_eliminated_columns[i];
301
299
  D_ASSERT(expr.type == ExpressionType::BOUND_COLUMN_REF);
@@ -4,6 +4,7 @@
4
4
 
5
5
  #include "duckdb/parser/transformer.hpp"
6
6
  #include "duckdb/common/types/decimal.hpp"
7
+ #include "duckdb/common/types/vector.hpp"
7
8
 
8
9
  namespace duckdb {
9
10
 
@@ -21,7 +22,21 @@ LogicalType Transformer::TransformTypeName(duckdb_libpgquery::PGTypeName &type_n
21
22
  if (base_type == LogicalTypeId::LIST) {
22
23
  throw ParserException("LIST is not valid as a stand-alone type");
23
24
  } else if (base_type == LogicalTypeId::ENUM) {
24
- throw ParserException("ENUM is not valid as a stand-alone type");
25
+ if (!type_name.typmods || type_name.typmods->length == 0) {
26
+ throw ParserException("Enum needs a set of entries");
27
+ }
28
+ Vector enum_vector(LogicalType::VARCHAR, type_name.typmods->length);
29
+ auto string_data = FlatVector::GetData<string_t>(enum_vector);
30
+ idx_t pos = 0;
31
+ for (auto node = type_name.typmods->head; node; node = node->next) {
32
+ auto constant_value = PGPointerCast<duckdb_libpgquery::PGAConst>(node->data.ptr_value);
33
+ if (constant_value->type != duckdb_libpgquery::T_PGAConst ||
34
+ constant_value->val.type != duckdb_libpgquery::T_PGString) {
35
+ throw ParserException("Enum type requires a set of strings as type modifiers");
36
+ }
37
+ string_data[pos++] = StringVector::AddString(enum_vector, constant_value->val.val.str);
38
+ }
39
+ return LogicalType::ENUM(enum_vector, type_name.typmods->length);
25
40
  } else if (base_type == LogicalTypeId::STRUCT) {
26
41
  if (!type_name.typmods || type_name.typmods->length == 0) {
27
42
  throw ParserException("Struct needs a name and entries");
@@ -56,7 +56,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateType(duckdb_libpgquery::
56
56
  D_ASSERT(stmt.query == nullptr);
57
57
  idx_t size = 0;
58
58
  auto ordered_array = PGListToVector(stmt.vals, size);
59
- info->type = LogicalType::ENUM(info->name, ordered_array, size);
59
+ info->type = LogicalType::ENUM(ordered_array, size);
60
60
  }
61
61
  } break;
62
62
 
@@ -138,10 +138,10 @@ static unique_ptr<Expression> PlanUncorrelatedSubquery(Binder &binder, BoundSubq
138
138
  }
139
139
  }
140
140
 
141
- static unique_ptr<LogicalDelimJoin>
141
+ static unique_ptr<LogicalComparisonJoin>
142
142
  CreateDuplicateEliminatedJoin(const vector<CorrelatedColumnInfo> &correlated_columns, JoinType join_type,
143
143
  unique_ptr<LogicalOperator> original_plan, bool perform_delim) {
144
- auto delim_join = make_uniq<LogicalDelimJoin>(join_type);
144
+ auto delim_join = make_uniq<LogicalComparisonJoin>(join_type, LogicalOperatorType::LOGICAL_DELIM_JOIN);
145
145
  if (!perform_delim) {
146
146
  // if we are not performing a delim join, we push a row_number() OVER() window operator on the LHS
147
147
  // and perform all duplicate elimination on that row number instead
@@ -165,7 +165,7 @@ CreateDuplicateEliminatedJoin(const vector<CorrelatedColumnInfo> &correlated_col
165
165
  return delim_join;
166
166
  }
167
167
 
168
- static void CreateDelimJoinConditions(LogicalDelimJoin &delim_join,
168
+ static void CreateDelimJoinConditions(LogicalComparisonJoin &delim_join,
169
169
  const vector<CorrelatedColumnInfo> &correlated_columns,
170
170
  vector<ColumnBinding> bindings, idx_t base_offset, bool perform_delim) {
171
171
  auto col_count = perform_delim ? correlated_columns.size() : 1;