duckdb 0.8.2-dev2133.0 → 0.8.2-dev2208.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 (93) 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/extra_type_info.cpp +24 -46
  11. package/src/duckdb/src/common/field_writer.cpp +0 -1
  12. package/src/duckdb/src/common/file_system.cpp +6 -6
  13. package/src/duckdb/src/common/filename_pattern.cpp +1 -1
  14. package/src/duckdb/src/common/gzip_file_system.cpp +7 -12
  15. package/src/duckdb/src/common/multi_file_reader.cpp +8 -5
  16. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +0 -9
  17. package/src/duckdb/src/common/types.cpp +12 -56
  18. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  19. package/src/duckdb/src/core_functions/scalar/union/union_tag.cpp +1 -1
  20. package/src/duckdb/src/execution/column_binding_resolver.cpp +3 -7
  21. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +1 -1
  22. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +0 -10
  23. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +2 -1
  24. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -6
  25. package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +1 -2
  26. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +14 -1
  27. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +3 -17
  28. package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +2 -5
  29. package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -5
  30. package/src/duckdb/src/function/cast/string_cast.cpp +0 -1
  31. package/src/duckdb/src/function/scalar_function.cpp +3 -19
  32. package/src/duckdb/src/function/table/read_csv.cpp +2 -1
  33. package/src/duckdb/src/function/table/system/test_all_types.cpp +4 -4
  34. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  35. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +0 -2
  36. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -4
  37. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +0 -6
  38. package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +2 -6
  39. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +0 -4
  40. package/src/duckdb/src/include/duckdb/common/file_system.hpp +8 -8
  41. package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +1 -1
  42. package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +1 -1
  43. package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +4 -0
  44. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +0 -4
  45. package/src/duckdb/src/include/duckdb/common/serializer.hpp +0 -7
  46. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +14 -10
  47. package/src/duckdb/src/include/duckdb/common/types.hpp +5 -10
  48. package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +2 -0
  49. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +0 -4
  50. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -2
  51. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +0 -3
  52. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +1 -1
  53. package/src/duckdb/src/include/duckdb/optimizer/deliminator.hpp +2 -2
  54. package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +0 -2
  55. package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +1 -2
  56. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +2 -4
  57. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +10 -7
  58. package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +5 -0
  59. package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +1 -0
  60. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +0 -3
  61. package/src/duckdb/src/main/attached_database.cpp +2 -2
  62. package/src/duckdb/src/main/database.cpp +1 -1
  63. package/src/duckdb/src/main/db_instance_cache.cpp +14 -6
  64. package/src/duckdb/src/main/extension/extension_install.cpp +1 -1
  65. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +1 -2
  66. package/src/duckdb/src/optimizer/compressed_materialization.cpp +0 -1
  67. package/src/duckdb/src/optimizer/deliminator.cpp +7 -7
  68. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +3 -5
  69. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +16 -1
  70. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +1 -1
  71. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +3 -3
  72. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +7 -23
  73. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +0 -24
  74. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +3 -5
  75. package/src/duckdb/src/planner/logical_operator.cpp +1 -6
  76. package/src/duckdb/src/planner/logical_operator_visitor.cpp +3 -6
  77. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +2 -14
  78. package/src/duckdb/src/planner/operator/logical_create_index.cpp +21 -12
  79. package/src/duckdb/src/planner/operator/logical_extension_operator.cpp +24 -0
  80. package/src/duckdb/src/planner/planner.cpp +0 -1
  81. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -5
  82. package/src/duckdb/src/storage/meta_block_reader.cpp +0 -9
  83. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +2 -0
  84. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +27 -0
  85. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  86. package/src/duckdb/src/storage/wal_replay.cpp +1 -3
  87. package/src/duckdb/ub_src_planner_operator.cpp +0 -4
  88. package/src/statement.cpp +0 -2
  89. package/test/columns.test.ts +1 -2
  90. package/src/duckdb/src/include/duckdb/planner/operator/logical_asof_join.hpp +0 -27
  91. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_join.hpp +0 -32
  92. package/src/duckdb/src/planner/operator/logical_asof_join.cpp +0 -14
  93. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +0 -25
@@ -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
@@ -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() {
@@ -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;
@@ -24,7 +24,6 @@
24
24
  #include "duckdb/planner/operator/logical_create_index.hpp"
25
25
  #include "duckdb/planner/operator/logical_create_table.hpp"
26
26
  #include "duckdb/planner/operator/logical_get.hpp"
27
- #include "duckdb/planner/operator/logical_distinct.hpp"
28
27
  #include "duckdb/planner/operator/logical_projection.hpp"
29
28
  #include "duckdb/planner/parsed_data/bound_create_table_info.hpp"
30
29
  #include "duckdb/planner/query_node/bound_select_node.hpp"
@@ -39,6 +38,7 @@
39
38
  #include "duckdb/main/database_manager.hpp"
40
39
  #include "duckdb/main/attached_database.hpp"
41
40
  #include "duckdb/catalog/duck_catalog.hpp"
41
+ #include "duckdb/function/table/table_scan.hpp"
42
42
 
43
43
  namespace duckdb {
44
44
 
@@ -260,23 +260,6 @@ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, optional
260
260
  } else {
261
261
  type = Catalog::GetType(context, INVALID_CATALOG, schema, user_type_name);
262
262
  }
263
- } else if (type.id() == LogicalTypeId::ENUM) {
264
- auto enum_type_name = EnumType::GetTypeName(type);
265
- optional_ptr<TypeCatalogEntry> enum_type_catalog;
266
- if (catalog) {
267
- enum_type_catalog =
268
- catalog->GetEntry<TypeCatalogEntry>(context, schema, enum_type_name, OnEntryNotFound::RETURN_NULL);
269
- if (!enum_type_catalog) {
270
- // look in the system catalog if the type was not found
271
- enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, SYSTEM_CATALOG, schema, enum_type_name,
272
- OnEntryNotFound::RETURN_NULL);
273
- }
274
- } else {
275
- enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, INVALID_CATALOG, schema, enum_type_name,
276
- OnEntryNotFound::RETURN_NULL);
277
- }
278
-
279
- EnumType::SetCatalog(type, enum_type_catalog.get());
280
263
  }
281
264
  }
282
265
 
@@ -483,10 +466,14 @@ unique_ptr<LogicalOperator> DuckCatalog::BindCreateIndex(Binder &binder, CreateS
483
466
  create_index_info->scan_types.emplace_back(LogicalType::ROW_TYPE);
484
467
  create_index_info->names = get.names;
485
468
  create_index_info->column_ids = get.column_ids;
469
+ auto &bind_data = get.bind_data->Cast<TableScanBindData>();
470
+ bind_data.is_create_index = true;
471
+ get.column_ids.push_back(COLUMN_IDENTIFIER_ROW_ID);
486
472
 
487
473
  // the logical CREATE INDEX also needs all fields to scan the referenced table
488
- return make_uniq<LogicalCreateIndex>(std::move(get.bind_data), std::move(create_index_info), std::move(expressions),
489
- table, std::move(get.function));
474
+ auto result = make_uniq<LogicalCreateIndex>(std::move(create_index_info), std::move(expressions), table);
475
+ result->children.push_back(std::move(plan));
476
+ return std::move(result);
490
477
  }
491
478
 
492
479
  BoundStatement Binder::Bind(CreateStatement &stmt) {
@@ -548,7 +535,6 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
548
535
  if (plan->type != LogicalOperatorType::LOGICAL_GET) {
549
536
  throw BinderException("Cannot create index on a view!");
550
537
  }
551
-
552
538
  result.plan = table.catalog.BindCreateIndex(*this, stmt, table, std::move(plan));
553
539
  break;
554
540
  }
@@ -653,8 +639,6 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
653
639
  // We set b to be an alias for the underlying type of a
654
640
  auto inner_type = Catalog::GetType(context, schema.catalog.GetName(), schema.name,
655
641
  UserType::GetTypeName(create_type_info.type));
656
- // clear to nullptr, we don't need this
657
- EnumType::SetCatalog(inner_type, nullptr);
658
642
  inner_type.SetAlias(create_type_info.name);
659
643
  create_type_info.type = inner_type;
660
644
  }
@@ -292,30 +292,6 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
292
292
  ExpressionBinder::TestCollation(context, StringType::GetCollation(column.Type()));
293
293
  }
294
294
  BindLogicalType(context, column.TypeMutable(), &result->schema.catalog);
295
- // We add a catalog dependency
296
- auto type_dependency = EnumType::GetCatalog(column.Type());
297
-
298
- if (type_dependency) {
299
- // Only if the USER comes from a create type
300
- if (schema.catalog.IsTemporaryCatalog() && column.Type().id() == LogicalTypeId::ENUM) {
301
- // for enum types that are used in tables in the temp catalog, we need to
302
- // make a copy of the enum type definition that is accessible there
303
- auto enum_type = type_dependency->user_type;
304
- auto &enum_entries = EnumType::GetValuesInsertOrder(enum_type);
305
- auto enum_size = EnumType::GetSize(enum_type);
306
- Vector copy_enum_entries_vec(LogicalType::VARCHAR, enum_size);
307
- auto copy_enum_entries_ptr = FlatVector::GetData<string_t>(copy_enum_entries_vec);
308
- auto enum_entries_ptr = FlatVector::GetData<string_t>(enum_entries);
309
- for (idx_t enum_idx = 0; enum_idx < enum_size; enum_idx++) {
310
- copy_enum_entries_ptr[enum_idx] =
311
- StringVector::AddStringOrBlob(copy_enum_entries_vec, enum_entries_ptr[enum_idx]);
312
- }
313
- auto copy_type = LogicalType::ENUM(EnumType::GetTypeName(enum_type), copy_enum_entries_vec, enum_size);
314
- column.SetType(copy_type);
315
- } else {
316
- result->dependencies.AddDependency(*type_dependency);
317
- }
318
- }
319
295
  }
320
296
  result->dependencies.VerifyDependencies(schema.catalog, result->Base().table);
321
297
  properties.allow_stream_result = false;
@@ -7,7 +7,6 @@
7
7
  #include "duckdb/planner/expression_iterator.hpp"
8
8
  #include "duckdb/planner/binder.hpp"
9
9
  #include "duckdb/planner/operator/logical_any_join.hpp"
10
- #include "duckdb/planner/operator/logical_asof_join.hpp"
11
10
  #include "duckdb/planner/operator/logical_comparison_join.hpp"
12
11
  #include "duckdb/planner/operator/logical_cross_product.hpp"
13
12
  #include "duckdb/planner/operator/logical_dependent_join.hpp"
@@ -193,12 +192,11 @@ unique_ptr<LogicalOperator> LogicalComparisonJoin::CreateJoin(ClientContext &con
193
192
  } else {
194
193
  // we successfully converted expressions into JoinConditions
195
194
  // create a LogicalComparisonJoin
196
- unique_ptr<LogicalComparisonJoin> comp_join;
195
+ auto logical_type = LogicalOperatorType::LOGICAL_COMPARISON_JOIN;
197
196
  if (reftype == JoinRefType::ASOF) {
198
- comp_join = make_uniq<LogicalAsOfJoin>(type);
199
- } else {
200
- comp_join = make_uniq<LogicalComparisonJoin>(type);
197
+ logical_type = LogicalOperatorType::LOGICAL_ASOF_JOIN;
201
198
  }
199
+ auto comp_join = make_uniq<LogicalComparisonJoin>(type, logical_type);
202
200
  comp_join->conditions = std::move(conditions);
203
201
  comp_join->children.push_back(std::move(left_child));
204
202
  comp_join->children.push_back(std::move(right_child));
@@ -131,7 +131,6 @@ void LogicalOperator::Verify(ClientContext &context) {
131
131
  }
132
132
  BufferedSerializer serializer;
133
133
  // We are serializing a query plan
134
- serializer.is_query_plan = true;
135
134
  try {
136
135
  expressions[expr_idx]->Serialize(serializer);
137
136
  } catch (NotImplementedException &ex) {
@@ -266,12 +265,8 @@ unique_ptr<LogicalOperator> LogicalOperator::Deserialize(Deserializer &deseriali
266
265
  break;
267
266
  case LogicalOperatorType::LOGICAL_JOIN:
268
267
  throw InternalException("LogicalJoin deserialize not supported");
269
- case LogicalOperatorType::LOGICAL_DELIM_JOIN:
270
- result = LogicalDelimJoin::Deserialize(state, reader);
271
- break;
272
268
  case LogicalOperatorType::LOGICAL_ASOF_JOIN:
273
- result = LogicalAsOfJoin::Deserialize(state, reader);
274
- break;
269
+ case LogicalOperatorType::LOGICAL_DELIM_JOIN:
275
270
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN:
276
271
  result = LogicalComparisonJoin::Deserialize(state, reader);
277
272
  break;