duckdb 0.7.2-dev1901.0 → 0.7.2-dev2233.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 (198) hide show
  1. package/binding.gyp +2 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/parquet/column_reader.cpp +3 -0
  4. package/src/duckdb/extension/parquet/include/parquet_writer.hpp +1 -1
  5. package/src/duckdb/extension/parquet/parquet_metadata.cpp +4 -2
  6. package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
  7. package/src/duckdb/src/common/arrow/arrow_appender.cpp +69 -44
  8. package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -1
  9. package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +20 -2
  10. package/src/duckdb/src/common/box_renderer.cpp +4 -2
  11. package/src/duckdb/src/common/constants.cpp +10 -1
  12. package/src/duckdb/src/common/filename_pattern.cpp +41 -0
  13. package/src/duckdb/src/common/hive_partitioning.cpp +144 -15
  14. package/src/duckdb/src/common/radix_partitioning.cpp +101 -369
  15. package/src/duckdb/src/common/row_operations/row_aggregate.cpp +8 -9
  16. package/src/duckdb/src/common/row_operations/row_external.cpp +1 -1
  17. package/src/duckdb/src/common/row_operations/row_gather.cpp +5 -3
  18. package/src/duckdb/src/common/row_operations/row_match.cpp +117 -22
  19. package/src/duckdb/src/common/row_operations/row_scatter.cpp +2 -2
  20. package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
  21. package/src/duckdb/src/common/sort/sort_state.cpp +2 -1
  22. package/src/duckdb/src/common/sort/sorted_block.cpp +1 -1
  23. package/src/duckdb/src/common/types/{column_data_allocator.cpp → column/column_data_allocator.cpp} +2 -2
  24. package/src/duckdb/src/common/types/{column_data_collection.cpp → column/column_data_collection.cpp} +29 -6
  25. package/src/duckdb/src/common/types/{column_data_collection_segment.cpp → column/column_data_collection_segment.cpp} +2 -1
  26. package/src/duckdb/src/common/types/{column_data_consumer.cpp → column/column_data_consumer.cpp} +1 -1
  27. package/src/duckdb/src/common/types/{partitioned_column_data.cpp → column/partitioned_column_data.cpp} +11 -9
  28. package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +316 -0
  29. package/src/duckdb/src/common/types/{row_data_collection.cpp → row/row_data_collection.cpp} +1 -1
  30. package/src/duckdb/src/common/types/{row_data_collection_scanner.cpp → row/row_data_collection_scanner.cpp} +2 -2
  31. package/src/duckdb/src/common/types/{row_layout.cpp → row/row_layout.cpp} +1 -1
  32. package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +465 -0
  33. package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +511 -0
  34. package/src/duckdb/src/common/types/row/tuple_data_iterator.cpp +96 -0
  35. package/src/duckdb/src/common/types/row/tuple_data_layout.cpp +119 -0
  36. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +1200 -0
  37. package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +170 -0
  38. package/src/duckdb/src/common/types/vector.cpp +1 -1
  39. package/src/duckdb/src/execution/aggregate_hashtable.cpp +252 -290
  40. package/src/duckdb/src/execution/join_hashtable.cpp +192 -328
  41. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +4 -4
  42. package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +3 -3
  43. package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +2 -3
  44. package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +2 -3
  45. package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +36 -21
  46. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +2 -2
  47. package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +1 -1
  48. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +2 -2
  49. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +166 -144
  50. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +5 -5
  51. package/src/duckdb/src/execution/operator/join/physical_join.cpp +2 -10
  52. package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +0 -1
  53. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +2 -2
  54. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +3 -0
  55. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +71 -22
  56. package/src/duckdb/src/execution/operator/persistent/csv_buffer.cpp +17 -13
  57. package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +0 -7
  58. package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +124 -29
  59. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +13 -11
  60. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +3 -2
  61. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +25 -24
  62. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +1 -1
  63. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +4 -3
  64. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +1 -1
  65. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
  66. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +3 -3
  67. package/src/duckdb/src/execution/partitionable_hashtable.cpp +9 -37
  68. package/src/duckdb/src/execution/physical_operator.cpp +1 -1
  69. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +19 -18
  70. package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +2 -1
  71. package/src/duckdb/src/execution/physical_plan/plan_execute.cpp +2 -2
  72. package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +5 -6
  73. package/src/duckdb/src/execution/physical_plan/plan_expression_get.cpp +2 -2
  74. package/src/duckdb/src/execution/physical_plan/plan_recursive_cte.cpp +3 -3
  75. package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -1
  76. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +39 -17
  77. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +2 -2
  78. package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +5 -5
  79. package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +2 -2
  80. package/src/duckdb/src/function/table/read_csv.cpp +124 -58
  81. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  82. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
  83. package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +1 -1
  84. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -0
  85. package/src/duckdb/src/include/duckdb/common/exception.hpp +3 -0
  86. package/src/duckdb/src/include/duckdb/common/fast_mem.hpp +528 -0
  87. package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +34 -0
  88. package/src/duckdb/src/include/duckdb/common/helper.hpp +10 -0
  89. package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +13 -3
  90. package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +8 -0
  91. package/src/duckdb/src/include/duckdb/common/perfect_map_set.hpp +34 -0
  92. package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +80 -27
  93. package/src/duckdb/src/include/duckdb/common/reference_map.hpp +38 -0
  94. package/src/duckdb/src/include/duckdb/common/row_operations/row_operations.hpp +7 -6
  95. package/src/duckdb/src/include/duckdb/common/sort/comparators.hpp +1 -1
  96. package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +1 -1
  97. package/src/duckdb/src/include/duckdb/common/sort/sort.hpp +1 -1
  98. package/src/duckdb/src/include/duckdb/common/sort/sorted_block.hpp +2 -2
  99. package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +1 -1
  100. package/src/duckdb/src/include/duckdb/common/types/{column_data_allocator.hpp → column/column_data_allocator.hpp} +4 -4
  101. package/src/duckdb/src/include/duckdb/common/types/{column_data_collection.hpp → column/column_data_collection.hpp} +4 -4
  102. package/src/duckdb/src/include/duckdb/common/types/{column_data_collection_iterators.hpp → column/column_data_collection_iterators.hpp} +2 -2
  103. package/src/duckdb/src/include/duckdb/common/types/{column_data_collection_segment.hpp → column/column_data_collection_segment.hpp} +3 -3
  104. package/src/duckdb/src/include/duckdb/common/types/{column_data_consumer.hpp → column/column_data_consumer.hpp} +8 -4
  105. package/src/duckdb/src/include/duckdb/common/types/{column_data_scan_states.hpp → column/column_data_scan_states.hpp} +1 -1
  106. package/src/duckdb/src/include/duckdb/common/types/{partitioned_column_data.hpp → column/partitioned_column_data.hpp} +15 -7
  107. package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +140 -0
  108. package/src/duckdb/src/include/duckdb/common/types/{row_data_collection.hpp → row/row_data_collection.hpp} +1 -1
  109. package/src/duckdb/src/include/duckdb/common/types/{row_data_collection_scanner.hpp → row/row_data_collection_scanner.hpp} +2 -2
  110. package/src/duckdb/src/include/duckdb/common/types/{row_layout.hpp → row/row_layout.hpp} +3 -1
  111. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +116 -0
  112. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +239 -0
  113. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_iterator.hpp +64 -0
  114. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_layout.hpp +113 -0
  115. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +124 -0
  116. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +74 -0
  117. package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -0
  118. package/src/duckdb/src/include/duckdb/common/types/value.hpp +4 -12
  119. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +34 -31
  120. package/src/duckdb/src/include/duckdb/execution/base_aggregate_hashtable.hpp +2 -2
  121. package/src/duckdb/src/include/duckdb/execution/execution_context.hpp +3 -2
  122. package/src/duckdb/src/include/duckdb/execution/expression_executor.hpp +1 -1
  123. package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +41 -67
  124. package/src/duckdb/src/include/duckdb/execution/nested_loop_join.hpp +1 -1
  125. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +2 -2
  126. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +1 -1
  127. package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +2 -2
  128. package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
  129. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -1
  130. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +0 -2
  131. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +2 -2
  132. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +1 -1
  133. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +4 -1
  134. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_buffer.hpp +8 -3
  135. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +5 -7
  136. package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +5 -1
  137. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +4 -1
  138. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -1
  139. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +1 -1
  140. package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +2 -2
  141. package/src/duckdb/src/include/duckdb/function/function.hpp +2 -0
  142. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +25 -0
  143. package/src/duckdb/src/include/duckdb/main/client_data.hpp +3 -0
  144. package/src/duckdb/src/include/duckdb/main/config.hpp +0 -2
  145. package/src/duckdb/src/include/duckdb/main/materialized_query_result.hpp +1 -1
  146. package/src/duckdb/src/include/duckdb/main/query_result.hpp +14 -1
  147. package/src/duckdb/src/include/duckdb/optimizer/expression_rewriter.hpp +3 -3
  148. package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +16 -16
  149. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_node.hpp +8 -8
  150. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +23 -15
  151. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +9 -10
  152. package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +18 -11
  153. package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +1 -1
  154. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +5 -1
  155. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +3 -2
  156. package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +4 -2
  157. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +9 -35
  158. package/src/duckdb/src/include/duckdb/planner/binder.hpp +24 -23
  159. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +3 -3
  160. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -1
  161. package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +3 -1
  162. package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +1 -1
  163. package/src/duckdb/src/main/appender.cpp +6 -6
  164. package/src/duckdb/src/main/client_context.cpp +1 -1
  165. package/src/duckdb/src/main/connection.cpp +2 -2
  166. package/src/duckdb/src/main/query_result.cpp +13 -0
  167. package/src/duckdb/src/main/settings/settings.cpp +3 -4
  168. package/src/duckdb/src/optimizer/expression_rewriter.cpp +4 -4
  169. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +91 -105
  170. package/src/duckdb/src/optimizer/join_order/join_node.cpp +5 -8
  171. package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +163 -160
  172. package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +30 -30
  173. package/src/duckdb/src/optimizer/join_order/query_graph.cpp +37 -38
  174. package/src/duckdb/src/parallel/executor.cpp +1 -1
  175. package/src/duckdb/src/parallel/meta_pipeline.cpp +2 -2
  176. package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +1 -1
  177. package/src/duckdb/src/parser/transform/tableref/transform_subquery.cpp +1 -1
  178. package/src/duckdb/src/parser/transformer.cpp +50 -9
  179. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +13 -0
  180. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +15 -5
  181. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +19 -17
  182. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +4 -4
  183. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +20 -21
  184. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +24 -22
  185. package/src/duckdb/src/planner/binder/tableref/bind_subqueryref.cpp +2 -2
  186. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +9 -0
  187. package/src/duckdb/src/planner/binder.cpp +16 -19
  188. package/src/duckdb/src/planner/expression_binder.cpp +8 -8
  189. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +3 -3
  190. package/src/duckdb/src/storage/checkpoint_manager.cpp +23 -23
  191. package/src/duckdb/src/storage/standard_buffer_manager.cpp +1 -1
  192. package/src/duckdb/src/storage/table_index_list.cpp +3 -3
  193. package/src/duckdb/src/verification/statement_verifier.cpp +1 -1
  194. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +5552 -5598
  195. package/src/duckdb/ub_src_common.cpp +2 -0
  196. package/src/duckdb/ub_src_common_types.cpp +0 -16
  197. package/src/duckdb/ub_src_common_types_column.cpp +10 -0
  198. package/src/duckdb/ub_src_common_types_row.cpp +20 -0
@@ -11,18 +11,20 @@
11
11
  #include "duckdb/common/common.hpp"
12
12
  #include "duckdb/common/vector.hpp"
13
13
  #include "duckdb/common/exception_format_value.hpp"
14
+ #include "duckdb/common/optional_ptr.hpp"
14
15
 
15
16
  namespace duckdb {
16
17
  class SQLStatement;
17
18
 
18
19
  class QueryErrorContext {
19
20
  public:
20
- explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = DConstants::INVALID_INDEX)
21
+ explicit QueryErrorContext(optional_ptr<SQLStatement> statement_ = nullptr,
22
+ idx_t query_location_ = DConstants::INVALID_INDEX)
21
23
  : statement(statement_), query_location(query_location_) {
22
24
  }
23
25
 
24
26
  //! The query statement
25
- SQLStatement *statement;
27
+ optional_ptr<SQLStatement> statement;
26
28
  //! The location in which the error should be thrown
27
29
  idx_t query_location;
28
30
 
@@ -49,19 +49,17 @@ class Transformer {
49
49
 
50
50
  public:
51
51
  explicit Transformer(ParserOptions &options);
52
- explicit Transformer(Transformer *parent);
52
+ explicit Transformer(Transformer &parent);
53
53
  ~Transformer();
54
54
 
55
55
  //! Transforms a Postgres parse tree into a set of SQL Statements
56
56
  bool TransformParseTree(duckdb_libpgquery::PGList *tree, vector<unique_ptr<SQLStatement>> &statements);
57
57
  string NodetypeToString(duckdb_libpgquery::PGNodeTag type);
58
58
 
59
- idx_t ParamCount() {
60
- return parent ? parent->ParamCount() : prepared_statement_parameter_index;
61
- }
59
+ idx_t ParamCount() const;
62
60
 
63
61
  private:
64
- Transformer *parent;
62
+ optional_ptr<Transformer> parent;
65
63
  //! Parser options
66
64
  ParserOptions &options;
67
65
  //! The current prepared statement parameter index
@@ -80,36 +78,12 @@ private:
80
78
  void Clear();
81
79
  bool InWindowDefinition();
82
80
 
83
- void SetParamCount(idx_t new_count) {
84
- if (parent) {
85
- parent->SetParamCount(new_count);
86
- } else {
87
- this->prepared_statement_parameter_index = new_count;
88
- }
89
- }
90
- void SetNamedParam(const string &name, int32_t index) {
91
- if (parent) {
92
- parent->SetNamedParam(name, index);
93
- } else {
94
- D_ASSERT(!named_param_map.count(name));
95
- this->named_param_map[name] = index;
96
- }
97
- }
98
- bool GetNamedParam(const string &name, int32_t &index) {
99
- if (parent) {
100
- return parent->GetNamedParam(name, index);
101
- } else {
102
- auto entry = named_param_map.find(name);
103
- if (entry == named_param_map.end()) {
104
- return false;
105
- }
106
- index = entry->second;
107
- return true;
108
- }
109
- }
110
- bool HasNamedParameters() const {
111
- return parent ? parent->HasNamedParameters() : !named_param_map.empty();
112
- }
81
+ Transformer &RootTransformer();
82
+ const Transformer &RootTransformer() const;
83
+ void SetParamCount(idx_t new_count);
84
+ void SetNamedParam(const string &name, int32_t index);
85
+ bool GetNamedParam(const string &name, int32_t &index);
86
+ bool HasNamedParameters() const;
113
87
 
114
88
  void AddPivotEntry(string enum_name, unique_ptr<SelectNode> source, unique_ptr<ParsedExpression> column);
115
89
  unique_ptr<SQLStatement> GenerateCreateEnumStmt(unique_ptr<CreatePivotEntry> entry);
@@ -21,6 +21,7 @@
21
21
  #include "duckdb/planner/bound_tokens.hpp"
22
22
  #include "duckdb/planner/expression/bound_columnref_expression.hpp"
23
23
  #include "duckdb/planner/logical_operator.hpp"
24
+ #include "duckdb/common/reference_map.hpp"
24
25
 
25
26
  namespace duckdb {
26
27
  class BoundResultModifier;
@@ -76,43 +77,43 @@ class Binder : public std::enable_shared_from_this<Binder> {
76
77
  friend class RecursiveSubqueryPlanner;
77
78
 
78
79
  public:
79
- DUCKDB_API static shared_ptr<Binder> CreateBinder(ClientContext &context, Binder *parent = nullptr,
80
+ DUCKDB_API static shared_ptr<Binder> CreateBinder(ClientContext &context, optional_ptr<Binder> parent = nullptr,
80
81
  bool inherit_ctes = true);
81
82
 
82
83
  //! The client context
83
84
  ClientContext &context;
84
85
  //! A mapping of names to common table expressions
85
- case_insensitive_map_t<CommonTableExpressionInfo *> CTE_bindings; // NOLINT
86
+ case_insensitive_map_t<reference<CommonTableExpressionInfo>> CTE_bindings; // NOLINT
86
87
  //! The CTEs that have already been bound
87
- unordered_set<CommonTableExpressionInfo *> bound_ctes;
88
+ reference_set_t<CommonTableExpressionInfo> bound_ctes;
88
89
  //! The bind context
89
90
  BindContext bind_context;
90
91
  //! The set of correlated columns bound by this binder (FIXME: this should probably be an unordered_set and not a
91
92
  //! vector)
92
93
  vector<CorrelatedColumnInfo> correlated_columns;
93
94
  //! The set of parameter expressions bound by this binder
94
- BoundParameterMap *parameters;
95
+ optional_ptr<BoundParameterMap> parameters;
95
96
  //! Statement properties
96
97
  StatementProperties properties;
97
98
  //! The alias for the currently processing subquery, if it exists
98
99
  string alias;
99
100
  //! Macro parameter bindings (if any)
100
- DummyBinding *macro_binding = nullptr;
101
+ optional_ptr<DummyBinding> macro_binding;
101
102
  //! The intermediate lambda bindings to bind nested lambdas (if any)
102
- vector<DummyBinding> *lambda_bindings = nullptr;
103
+ optional_ptr<vector<DummyBinding>> lambda_bindings;
103
104
 
104
105
  public:
105
106
  DUCKDB_API BoundStatement Bind(SQLStatement &statement);
106
107
  DUCKDB_API BoundStatement Bind(QueryNode &node);
107
108
 
108
109
  unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info);
109
- unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry *schema);
110
+ unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry &schema);
110
111
 
111
112
  vector<unique_ptr<Expression>> BindCreateIndexExpressions(TableCatalogEntry *table, CreateIndexInfo *info);
112
113
 
113
114
  void BindCreateViewInfo(CreateViewInfo &base);
114
- SchemaCatalogEntry *BindSchema(CreateInfo &info);
115
- SchemaCatalogEntry *BindCreateFunctionInfo(CreateInfo &info);
115
+ SchemaCatalogEntry &BindSchema(CreateInfo &info);
116
+ SchemaCatalogEntry &BindCreateFunctionInfo(CreateInfo &info);
116
117
 
117
118
  //! Check usage, and cast named parameters to their types
118
119
  static void BindNamedParameters(named_parameter_type_map_t &types, named_parameter_map_t &values,
@@ -125,22 +126,22 @@ public:
125
126
  idx_t GenerateTableIndex();
126
127
 
127
128
  //! Add a common table expression to the binder
128
- void AddCTE(const string &name, CommonTableExpressionInfo *cte);
129
+ void AddCTE(const string &name, CommonTableExpressionInfo &cte);
129
130
  //! Find a common table expression by name; returns nullptr if none exists
130
- CommonTableExpressionInfo *FindCTE(const string &name, bool skip = false);
131
+ optional_ptr<CommonTableExpressionInfo> FindCTE(const string &name, bool skip = false);
131
132
 
132
- bool CTEIsAlreadyBound(CommonTableExpressionInfo *cte);
133
+ bool CTEIsAlreadyBound(CommonTableExpressionInfo &cte);
133
134
 
134
135
  //! Add the view to the set of currently bound views - used for detecting recursive view definitions
135
- void AddBoundView(ViewCatalogEntry *view);
136
+ void AddBoundView(ViewCatalogEntry &view);
136
137
 
137
- void PushExpressionBinder(ExpressionBinder *binder);
138
+ void PushExpressionBinder(ExpressionBinder &binder);
138
139
  void PopExpressionBinder();
139
- void SetActiveBinder(ExpressionBinder *binder);
140
- ExpressionBinder *GetActiveBinder();
140
+ void SetActiveBinder(ExpressionBinder &binder);
141
+ ExpressionBinder &GetActiveBinder();
141
142
  bool HasActiveBinder();
142
143
 
143
- vector<ExpressionBinder *> &GetActiveBinders();
144
+ vector<reference<ExpressionBinder>> &GetActiveBinders();
144
145
 
145
146
  void MergeCorrelatedColumns(vector<CorrelatedColumnInfo> &other);
146
147
  //! Add a correlated column to this binder (if it does not exist)
@@ -184,7 +185,7 @@ public:
184
185
  BindingMode GetBindingMode();
185
186
  void AddTableName(string table_name);
186
187
  const unordered_set<string> &GetTableNames();
187
- SQLStatement *GetRootStatement() {
188
+ optional_ptr<SQLStatement> GetRootStatement() {
188
189
  return root_statement;
189
190
  }
190
191
 
@@ -194,7 +195,7 @@ private:
194
195
  //! The parent binder (if any)
195
196
  shared_ptr<Binder> parent;
196
197
  //! The vector of active binders
197
- vector<ExpressionBinder *> active_binders;
198
+ vector<reference<ExpressionBinder>> active_binders;
198
199
  //! The count of bound_tables
199
200
  idx_t bound_tables;
200
201
  //! Whether or not the binder has any unplanned subqueries that still need to be planned
@@ -206,13 +207,13 @@ private:
206
207
  //! Whether or not the binder can contain NULLs as the root of expressions
207
208
  bool can_contain_nulls = false;
208
209
  //! The root statement of the query that is currently being parsed
209
- SQLStatement *root_statement = nullptr;
210
+ optional_ptr<SQLStatement> root_statement;
210
211
  //! Binding mode
211
212
  BindingMode mode = BindingMode::STANDARD_BINDING;
212
213
  //! Table names extracted for BindingMode::EXTRACT_NAMES
213
214
  unordered_set<string> table_names;
214
215
  //! The set of bound views
215
- unordered_set<ViewCatalogEntry *> bound_views;
216
+ reference_set_t<ViewCatalogEntry> bound_views;
216
217
 
217
218
  private:
218
219
  //! Bind the expressions of generated columns to check for errors
@@ -273,7 +274,7 @@ private:
273
274
 
274
275
  unique_ptr<BoundTableRef> Bind(BaseTableRef &ref);
275
276
  unique_ptr<BoundTableRef> Bind(JoinRef &ref);
276
- unique_ptr<BoundTableRef> Bind(SubqueryRef &ref, CommonTableExpressionInfo *cte = nullptr);
277
+ unique_ptr<BoundTableRef> Bind(SubqueryRef &ref, optional_ptr<CommonTableExpressionInfo> cte = nullptr);
277
278
  unique_ptr<BoundTableRef> Bind(TableFunctionRef &ref);
278
279
  unique_ptr<BoundTableRef> Bind(EmptyTableRef &ref);
279
280
  unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
@@ -349,7 +350,7 @@ private:
349
350
 
350
351
  //! If only a schema name is provided (e.g. "a.b") then figure out if "a" is a schema or a catalog name
351
352
  void BindSchemaOrCatalog(string &catalog_name, string &schema_name);
352
- SchemaCatalogEntry *BindCreateSchema(CreateInfo &info);
353
+ SchemaCatalogEntry &BindCreateSchema(CreateInfo &info);
353
354
 
354
355
  unique_ptr<BoundQueryNode> BindSelectNode(SelectNode &statement, unique_ptr<BoundTableRef> from_table);
355
356
 
@@ -59,8 +59,8 @@ public:
59
59
  //! be added. Defaults to INVALID.
60
60
  LogicalType target_type;
61
61
 
62
- DummyBinding *macro_binding;
63
- vector<DummyBinding> *lambda_bindings = nullptr;
62
+ optional_ptr<DummyBinding> macro_binding;
63
+ optional_ptr<vector<DummyBinding>> lambda_bindings;
64
64
 
65
65
  public:
66
66
  unique_ptr<Expression> Bind(unique_ptr<ParsedExpression> &expr, LogicalType *result_type = nullptr,
@@ -146,7 +146,7 @@ protected:
146
146
 
147
147
  Binder &binder;
148
148
  ClientContext &context;
149
- ExpressionBinder *stored_binder;
149
+ optional_ptr<ExpressionBinder> stored_binder;
150
150
  vector<BoundColumnReferenceInfo> bound_columns;
151
151
  };
152
152
 
@@ -8,7 +8,7 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/common/types/column_data_collection.hpp"
11
+ #include "duckdb/common/types/column/column_data_collection.hpp"
12
12
  #include "duckdb/planner/logical_operator.hpp"
13
13
 
14
14
  namespace duckdb {
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include "duckdb/planner/logical_operator.hpp"
12
12
  #include "duckdb/function/copy_function.hpp"
13
+ #include "duckdb/common/filename_pattern.hpp"
13
14
  #include "duckdb/common/local_file_system.hpp"
14
15
 
15
16
  namespace duckdb {
@@ -27,7 +28,8 @@ public:
27
28
  unique_ptr<FunctionData> bind_data;
28
29
  std::string file_path;
29
30
  bool use_tmp_file;
30
- bool allow_overwrite;
31
+ FilenamePattern filename_pattern;
32
+ bool overwrite_or_ignore;
31
33
  bool per_thread_output;
32
34
 
33
35
  bool partition_output;
@@ -35,7 +35,7 @@ public:
35
35
 
36
36
  void AddIndex(unique_ptr<Index> index);
37
37
 
38
- void RemoveIndex(Index *index);
38
+ void RemoveIndex(Index &index);
39
39
 
40
40
  bool Empty();
41
41
 
@@ -3,15 +3,15 @@
3
3
  #include "duckdb/catalog/catalog_entry/duck_table_entry.hpp"
4
4
  #include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
5
5
  #include "duckdb/common/exception.hpp"
6
- #include "duckdb/main/connection.hpp"
6
+ #include "duckdb/common/operator/cast_operators.hpp"
7
+ #include "duckdb/common/operator/decimal_cast_operators.hpp"
8
+ #include "duckdb/common/operator/string_cast.hpp"
9
+ #include "duckdb/common/string_util.hpp"
10
+ #include "duckdb/common/types/column/column_data_collection.hpp"
7
11
  #include "duckdb/main/client_context.hpp"
12
+ #include "duckdb/main/connection.hpp"
8
13
  #include "duckdb/main/database.hpp"
9
14
  #include "duckdb/storage/data_table.hpp"
10
- #include "duckdb/common/string_util.hpp"
11
- #include "duckdb/common/operator/cast_operators.hpp"
12
- #include "duckdb/common/operator/string_cast.hpp"
13
- #include "duckdb/common/types/column_data_collection.hpp"
14
- #include "duckdb/common/operator/decimal_cast_operators.hpp"
15
15
 
16
16
  namespace duckdb {
17
17
 
@@ -10,7 +10,7 @@
10
10
  #include "duckdb/common/serializer/buffered_deserializer.hpp"
11
11
  #include "duckdb/common/serializer/buffered_file_writer.hpp"
12
12
  #include "duckdb/common/serializer/buffered_serializer.hpp"
13
- #include "duckdb/common/types/column_data_collection.hpp"
13
+ #include "duckdb/common/types/column/column_data_collection.hpp"
14
14
  #include "duckdb/execution/column_binding_resolver.hpp"
15
15
  #include "duckdb/execution/operator/helper/physical_result_collector.hpp"
16
16
  #include "duckdb/execution/physical_plan_generator.hpp"
@@ -1,6 +1,8 @@
1
1
  #include "duckdb/main/connection.hpp"
2
2
 
3
+ #include "duckdb/common/types/column/column_data_collection.hpp"
3
4
  #include "duckdb/execution/operator/persistent/parallel_csv_reader.hpp"
5
+ #include "duckdb/function/table/read_csv.hpp"
4
6
  #include "duckdb/main/appender.hpp"
5
7
  #include "duckdb/main/client_context.hpp"
6
8
  #include "duckdb/main/connection_manager.hpp"
@@ -14,8 +16,6 @@
14
16
  #include "duckdb/main/relation/view_relation.hpp"
15
17
  #include "duckdb/parser/parser.hpp"
16
18
  #include "duckdb/planner/logical_operator.hpp"
17
- #include "duckdb/common/types/column_data_collection.hpp"
18
- #include "duckdb/function/table/read_csv.hpp"
19
19
 
20
20
  namespace duckdb {
21
21
 
@@ -58,6 +58,19 @@ QueryResult::QueryResult(QueryResultType type, StatementType statement_type, Sta
58
58
  client_properties(std::move(client_properties_p)) {
59
59
  }
60
60
 
61
+ bool CurrentChunk::Valid() {
62
+ if (data_chunk) {
63
+ if (position < data_chunk->size()) {
64
+ return true;
65
+ }
66
+ }
67
+ return false;
68
+ }
69
+
70
+ idx_t CurrentChunk::RemainingSize() {
71
+ return data_chunk->size() - position;
72
+ }
73
+
61
74
  QueryResult::QueryResult(QueryResultType type, PreservedError error) : BaseQueryResult(type, std::move(error)) {
62
75
  }
63
76
 
@@ -512,16 +512,15 @@ Value EnableProgressBarPrintSetting::GetSetting(ClientContext &context) {
512
512
  // Experimental Parallel CSV
513
513
  //===--------------------------------------------------------------------===//
514
514
  void ExperimentalParallelCSVSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
515
- config.options.experimental_parallel_csv_reader = input.GetValue<bool>();
515
+ Printer::Print("experimental_parallel_csv is deprecated and will be removed with the next release - the parallel "
516
+ "CSV reader is now standard and does not need to be manually enabled anymore 1");
516
517
  }
517
518
 
518
519
  void ExperimentalParallelCSVSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
519
- config.options.experimental_parallel_csv_reader = DBConfig().options.experimental_parallel_csv_reader;
520
520
  }
521
521
 
522
522
  Value ExperimentalParallelCSVSetting::GetSetting(ClientContext &context) {
523
- auto &config = DBConfig::GetConfig(context);
524
- return Value::BIGINT(config.options.experimental_parallel_csv_reader);
523
+ return Value();
525
524
  }
526
525
 
527
526
  //===--------------------------------------------------------------------===//
@@ -9,14 +9,14 @@
9
9
 
10
10
  namespace duckdb {
11
11
 
12
- unique_ptr<Expression> ExpressionRewriter::ApplyRules(LogicalOperator &op, const vector<Rule *> &rules,
12
+ unique_ptr<Expression> ExpressionRewriter::ApplyRules(LogicalOperator &op, const vector<reference<Rule>> &rules,
13
13
  unique_ptr<Expression> expr, bool &changes_made, bool is_root) {
14
14
  for (auto &rule : rules) {
15
15
  vector<reference<Expression>> bindings;
16
- if (rule->root->Match(*expr, bindings)) {
16
+ if (rule.get().root->Match(*expr, bindings)) {
17
17
  // the rule matches! try to apply it
18
18
  bool rule_made_change = false;
19
- auto result = rule->Apply(op, bindings, rule_made_change, is_root);
19
+ auto result = rule.get().Apply(op, bindings, rule_made_change, is_root);
20
20
  if (result) {
21
21
  changes_made = true;
22
22
  // the base node changed: the rule applied changes
@@ -63,7 +63,7 @@ void ExpressionRewriter::VisitOperator(LogicalOperator &op) {
63
63
  // this rule does not apply to this type of LogicalOperator
64
64
  continue;
65
65
  }
66
- to_apply_rules.push_back(rule.get());
66
+ to_apply_rules.push_back(*rule);
67
67
  }
68
68
  if (to_apply_rules.empty()) {
69
69
  // no rules to apply on this node