duckdb 0.7.2-dev1637.0 → 0.7.2-dev1671.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 (65) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +1 -1
  3. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +10 -0
  4. package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +0 -5
  5. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -0
  6. package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +0 -5
  7. package/src/duckdb/src/execution/operator/helper/physical_streaming_limit.cpp +2 -2
  8. package/src/duckdb/src/execution/operator/set/physical_union.cpp +13 -2
  9. package/src/duckdb/src/execution/physical_operator.cpp +0 -15
  10. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +24 -4
  11. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  12. package/src/duckdb/src/include/duckdb/common/enums/order_preservation_type.hpp +24 -0
  13. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +9 -2
  14. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +8 -1
  15. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_streaming_window.hpp +2 -2
  16. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +6 -0
  17. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +6 -3
  18. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +0 -1
  19. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +4 -0
  20. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +5 -1
  21. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +5 -1
  22. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +4 -0
  23. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -0
  24. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +4 -0
  25. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +4 -0
  26. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +4 -0
  27. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +4 -0
  28. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +4 -1
  29. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +4 -0
  30. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_limit.hpp +1 -1
  31. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +4 -0
  32. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +4 -0
  33. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +6 -5
  34. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +4 -1
  35. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +3 -4
  36. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +7 -1
  37. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +8 -1
  38. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +7 -0
  39. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +4 -0
  40. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +5 -1
  41. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +4 -0
  42. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +4 -0
  43. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +8 -0
  44. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +4 -0
  45. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +4 -0
  46. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +4 -0
  47. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +4 -0
  48. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +4 -0
  49. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +3 -0
  50. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +4 -0
  51. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +4 -0
  52. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +4 -0
  53. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +4 -0
  54. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +4 -0
  55. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +4 -0
  56. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +4 -0
  57. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +4 -0
  58. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +4 -0
  59. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +4 -0
  60. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +4 -0
  61. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +4 -0
  62. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +15 -9
  63. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +1 -1
  64. package/src/duckdb/src/main/extension/extension_helper.cpp +17 -2
  65. package/src/duckdb/src/parallel/pipeline.cpp +24 -9
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.2-dev1637.0",
5
+ "version": "0.7.2-dev1671.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -843,7 +843,7 @@ public:
843
843
  auto &grouping_gstate = ht_state.grouping_states[sidx];
844
844
  count += grouping.table_data.Size(*grouping_gstate.table_state);
845
845
  }
846
- return MaxValue<idx_t>(1, count / RowGroup::ROW_GROUP_SIZE);
846
+ return MaxValue<idx_t>(1, count / STANDARD_VECTOR_SIZE);
847
847
  }
848
848
  };
849
849
 
@@ -166,6 +166,16 @@ public:
166
166
  }
167
167
  };
168
168
 
169
+ bool PhysicalUngroupedAggregate::SinkOrderDependent() const {
170
+ for (auto &expr : aggregates) {
171
+ auto &aggr = expr->Cast<BoundAggregateExpression>();
172
+ if (aggr.function.order_dependent == AggregateOrderDependent::ORDER_DEPENDENT) {
173
+ return true;
174
+ }
175
+ }
176
+ return false;
177
+ }
178
+
169
179
  unique_ptr<GlobalSinkState> PhysicalUngroupedAggregate::GetGlobalSinkState(ClientContext &context) const {
170
180
  return make_uniq<UngroupedAggregateGlobalState>(*this, context);
171
181
  }
@@ -12,11 +12,6 @@ vector<PhysicalOperator *> PhysicalExecute::GetChildren() const {
12
12
  return {plan};
13
13
  }
14
14
 
15
- bool PhysicalExecute::AllOperatorsPreserveOrder() const {
16
- D_ASSERT(plan);
17
- return plan->AllOperatorsPreserveOrder();
18
- }
19
-
20
15
  void PhysicalExecute::BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) {
21
16
  // EXECUTE statement: build pipeline on child
22
17
  meta_pipeline.Build(plan);
@@ -75,4 +75,8 @@ bool PhysicalMaterializedCollector::ParallelSink() const {
75
75
  return parallel;
76
76
  }
77
77
 
78
+ bool PhysicalMaterializedCollector::SinkOrderDependent() const {
79
+ return true;
80
+ }
81
+
78
82
  } // namespace duckdb
@@ -35,11 +35,6 @@ vector<PhysicalOperator *> PhysicalResultCollector::GetChildren() const {
35
35
  return {plan};
36
36
  }
37
37
 
38
- bool PhysicalResultCollector::AllOperatorsPreserveOrder() const {
39
- D_ASSERT(plan);
40
- return plan->AllOperatorsPreserveOrder();
41
- }
42
-
43
38
  void PhysicalResultCollector::BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) {
44
39
  // operator is a sink, build a pipeline
45
40
  sink_state.reset();
@@ -60,8 +60,8 @@ OperatorResultType PhysicalStreamingLimit::Execute(ExecutionContext &context, Da
60
60
  return OperatorResultType::NEED_MORE_INPUT;
61
61
  }
62
62
 
63
- bool PhysicalStreamingLimit::IsOrderDependent() const {
64
- return !parallel;
63
+ OrderPreservationType PhysicalStreamingLimit::OperatorOrder() const {
64
+ return OrderPreservationType::FIXED_ORDER;
65
65
  }
66
66
 
67
67
  bool PhysicalStreamingLimit::ParallelOperator() const {
@@ -22,8 +22,19 @@ void PhysicalUnion::BuildPipelines(Pipeline &current, MetaPipeline &meta_pipelin
22
22
 
23
23
  // order matters if any of the downstream operators are order dependent,
24
24
  // or if the sink preserves order, but does not support batch indices to do so
25
- auto snk = meta_pipeline.GetSink();
26
- bool order_matters = current.IsOrderDependent() || (snk && snk->IsOrderPreserving() && !snk->RequiresBatchIndex());
25
+ auto sink = meta_pipeline.GetSink();
26
+ bool order_matters = false;
27
+ if (current.IsOrderDependent()) {
28
+ order_matters = true;
29
+ }
30
+ if (sink) {
31
+ if (sink->SinkOrderDependent() && !sink->RequiresBatchIndex()) {
32
+ order_matters = true;
33
+ }
34
+ if (!sink->ParallelSink()) {
35
+ order_matters = true;
36
+ }
37
+ }
27
38
 
28
39
  // create a union pipeline that is identical to 'current'
29
40
  auto union_pipeline = meta_pipeline.CreateUnionPipeline(current, order_matters);
@@ -184,21 +184,6 @@ bool PhysicalOperator::AllSourcesSupportBatchIndex() const {
184
184
  return true;
185
185
  }
186
186
 
187
- bool PhysicalOperator::AllOperatorsPreserveOrder() const {
188
- if (type == PhysicalOperatorType::ORDER_BY) {
189
- return true;
190
- }
191
- if (!IsOrderPreserving()) {
192
- return false;
193
- }
194
- for (auto &child : children) {
195
- if (!child->AllOperatorsPreserveOrder()) {
196
- return false;
197
- }
198
- }
199
- return true;
200
- }
201
-
202
187
  void PhysicalOperator::Verify() {
203
188
  #ifdef DEBUG
204
189
  auto sources = GetSources();
@@ -10,14 +10,34 @@
10
10
 
11
11
  namespace duckdb {
12
12
 
13
+ static OrderPreservationType OrderPreservationRecursive(PhysicalOperator &op) {
14
+ if (op.IsSource()) {
15
+ return op.SourceOrder();
16
+ }
17
+ for (auto &child : op.children) {
18
+ auto child_preservation = OrderPreservationRecursive(*child);
19
+ if (child_preservation != OrderPreservationType::INSERTION_ORDER) {
20
+ return child_preservation;
21
+ }
22
+ }
23
+ return OrderPreservationType::INSERTION_ORDER;
24
+ }
25
+
13
26
  bool PhysicalPlanGenerator::PreserveInsertionOrder(ClientContext &context, PhysicalOperator &plan) {
14
27
  auto &config = DBConfig::GetConfig(context);
15
- if (!config.options.preserve_insertion_order) {
16
- // preserving insertion order is disabled by config
28
+
29
+ auto preservation_type = OrderPreservationRecursive(plan);
30
+ if (preservation_type == OrderPreservationType::FIXED_ORDER) {
31
+ // always need to maintain preservation order
32
+ return true;
33
+ }
34
+ if (preservation_type == OrderPreservationType::NO_ORDER) {
35
+ // never need to preserve order
17
36
  return false;
18
37
  }
19
- if (!plan.AllOperatorsPreserveOrder()) {
20
- // the plan has no order defined: no need to preserve insertion order
38
+ // preserve insertion order - check flags
39
+ if (!config.options.preserve_insertion_order) {
40
+ // preserving insertion order is disabled by config
21
41
  return false;
22
42
  }
23
43
  return true;
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.7.2-dev1637"
2
+ #define DUCKDB_VERSION "0.7.2-dev1671"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "bacede9532"
5
+ #define DUCKDB_SOURCE_ID "846a32b4c8"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -0,0 +1,24 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // src/include/duckdb/common/enums/order_preservation_type.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/common/constants.hpp"
12
+
13
+ namespace duckdb {
14
+
15
+ //===--------------------------------------------------------------------===//
16
+ // Order Preservation Type
17
+ //===--------------------------------------------------------------------===//
18
+ enum class OrderPreservationType : uint8_t {
19
+ NO_ORDER, // the operator makes no guarantees on order preservation (i.e. it might re-order the entire input)
20
+ INSERTION_ORDER, // the operator maintains the order of the child operators
21
+ FIXED_ORDER // the operator outputs rows in a fixed order that must be maintained (e.g. ORDER BY)
22
+ };
23
+
24
+ } // namespace duckdb
@@ -93,12 +93,15 @@ public:
93
93
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
94
94
  LocalSourceState &lstate) const override;
95
95
 
96
+ bool IsSource() const override {
97
+ return true;
98
+ }
96
99
  bool ParallelSource() const override {
97
100
  return true;
98
101
  }
99
102
 
100
- bool IsOrderPreserving() const override {
101
- return false;
103
+ OrderPreservationType SourceOrder() const override {
104
+ return OrderPreservationType::NO_ORDER;
102
105
  }
103
106
 
104
107
  public:
@@ -122,6 +125,10 @@ public:
122
125
  return true;
123
126
  }
124
127
 
128
+ bool SinkOrderDependent() const override {
129
+ return false;
130
+ }
131
+
125
132
  public:
126
133
  string ParamsToString() const override;
127
134
  //! Toggle multi-scan capability on a hash table, which prevents the scan of the aggregate from being destructive
@@ -37,6 +37,13 @@ public:
37
37
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
38
38
  LocalSourceState &lstate) const override;
39
39
 
40
+ bool IsSource() const override {
41
+ return true;
42
+ }
43
+ OrderPreservationType SourceOrder() const override {
44
+ return OrderPreservationType::NO_ORDER;
45
+ }
46
+
40
47
  public:
41
48
  // Sink interface
42
49
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
@@ -59,7 +66,7 @@ public:
59
66
  return true;
60
67
  }
61
68
 
62
- bool IsOrderPreserving() const override {
69
+ bool SinkOrderDependent() const override {
63
70
  return false;
64
71
  }
65
72
 
@@ -33,8 +33,8 @@ public:
33
33
  OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
34
34
  GlobalOperatorState &gstate, OperatorState &state) const override;
35
35
 
36
- bool IsOrderDependent() const override {
37
- return true;
36
+ OrderPreservationType OperatorOrder() const override {
37
+ return OrderPreservationType::FIXED_ORDER;
38
38
  }
39
39
 
40
40
  string ParamsToString() const override;
@@ -39,6 +39,10 @@ public:
39
39
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
40
40
  LocalSourceState &lstate) const override;
41
41
 
42
+ bool IsSource() const override {
43
+ return true;
44
+ }
45
+
42
46
  public:
43
47
  // Sink interface
44
48
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
@@ -60,6 +64,8 @@ public:
60
64
  return true;
61
65
  }
62
66
 
67
+ bool SinkOrderDependent() const override;
68
+
63
69
  private:
64
70
  //! Finalize the distinct aggregates
65
71
  SinkFinalizeType FinalizeDistinct(Pipeline &pipeline, Event &event, ClientContext &context,
@@ -38,12 +38,15 @@ public:
38
38
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
39
39
  LocalSourceState &lstate) const override;
40
40
 
41
+ bool IsSource() const override {
42
+ return true;
43
+ }
41
44
  bool ParallelSource() const override {
42
45
  return true;
43
46
  }
44
47
 
45
- bool IsOrderPreserving() const override {
46
- return true;
48
+ OrderPreservationType SourceOrder() const override {
49
+ return OrderPreservationType::NO_ORDER;
47
50
  }
48
51
 
49
52
  public:
@@ -65,7 +68,7 @@ public:
65
68
  return !is_order_dependent;
66
69
  }
67
70
 
68
- bool IsOrderDependent() const override {
71
+ bool SinkOrderDependent() const override {
69
72
  return is_order_dependent;
70
73
  }
71
74
 
@@ -28,7 +28,6 @@ public:
28
28
  vector<PhysicalOperator *> GetChildren() const override;
29
29
 
30
30
  public:
31
- bool AllOperatorsPreserveOrder() const override;
32
31
  void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) override;
33
32
  };
34
33
 
@@ -28,6 +28,10 @@ public:
28
28
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
29
29
  LocalSourceState &lstate) const override;
30
30
 
31
+ bool IsSource() const override {
32
+ return true;
33
+ }
34
+
31
35
  public:
32
36
  // Sink Interface
33
37
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
@@ -28,7 +28,7 @@ public:
28
28
  unique_ptr<Expression> offset_expression;
29
29
 
30
30
  public:
31
- bool IsOrderDependent() const override {
31
+ bool SinkOrderDependent() const override {
32
32
  return true;
33
33
  }
34
34
 
@@ -38,6 +38,10 @@ public:
38
38
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
39
39
  LocalSourceState &lstate) const override;
40
40
 
41
+ bool IsSource() const override {
42
+ return true;
43
+ }
44
+
41
45
  public:
42
46
  // Sink Interface
43
47
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
@@ -33,7 +33,7 @@ public:
33
33
  unique_ptr<Expression> offset_expression;
34
34
 
35
35
  public:
36
- bool IsOrderDependent() const override {
36
+ bool SinkOrderDependent() const override {
37
37
  return true;
38
38
  }
39
39
 
@@ -43,6 +43,10 @@ public:
43
43
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
44
44
  LocalSourceState &lstate) const override;
45
45
 
46
+ bool IsSource() const override {
47
+ return true;
48
+ }
49
+
46
50
  public:
47
51
  // Sink Interface
48
52
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -30,6 +30,10 @@ public:
30
30
  // Source interface
31
31
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
32
32
  LocalSourceState &lstate) const override;
33
+
34
+ bool IsSource() const override {
35
+ return true;
36
+ }
33
37
  };
34
38
 
35
39
  } // namespace duckdb
@@ -31,6 +31,7 @@ public:
31
31
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
32
32
 
33
33
  bool ParallelSink() const override;
34
+ bool SinkOrderDependent() const override;
34
35
  };
35
36
 
36
37
  } // namespace duckdb
@@ -34,6 +34,10 @@ public:
34
34
  // Source interface
35
35
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
36
36
  LocalSourceState &lstate) const override;
37
+
38
+ bool IsSource() const override {
39
+ return true;
40
+ }
37
41
  };
38
42
 
39
43
  } // namespace duckdb
@@ -31,6 +31,10 @@ public:
31
31
  // Source interface
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -28,6 +28,10 @@ public:
28
28
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
29
29
  LocalSourceState &lstate) const override;
30
30
 
31
+ bool IsSource() const override {
32
+ return true;
33
+ }
34
+
31
35
  public:
32
36
  // Sink interface
33
37
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
@@ -33,6 +33,10 @@ public:
33
33
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
34
34
  LocalSourceState &lstate) const override;
35
35
 
36
+ bool IsSource() const override {
37
+ return true;
38
+ }
39
+
36
40
  public:
37
41
  const std::string name;
38
42
  const SetScope scope;
@@ -37,8 +37,11 @@ public:
37
37
 
38
38
  public:
39
39
  vector<PhysicalOperator *> GetChildren() const override;
40
- bool AllOperatorsPreserveOrder() const override;
41
40
  void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) override;
41
+
42
+ bool IsSource() const override {
43
+ return true;
44
+ }
42
45
  };
43
46
 
44
47
  } // namespace duckdb
@@ -33,6 +33,10 @@ public:
33
33
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
34
34
  LocalSourceState &lstate) const override;
35
35
 
36
+ bool IsSource() const override {
37
+ return true;
38
+ }
39
+
36
40
  static void SetExtensionVariable(ClientContext &context, ExtensionOption &extension_option, const string &name,
37
41
  SetScope scope, const Value &value);
38
42
 
@@ -35,7 +35,7 @@ public:
35
35
  OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
36
36
  GlobalOperatorState &gstate, OperatorState &state) const override;
37
37
 
38
- bool IsOrderDependent() const override;
38
+ OrderPreservationType OperatorOrder() const override;
39
39
  bool ParallelOperator() const override;
40
40
  };
41
41
 
@@ -29,6 +29,10 @@ public:
29
29
  public:
30
30
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
31
31
  LocalSourceState &lstate) const override;
32
+
33
+ bool IsSource() const override {
34
+ return true;
35
+ }
32
36
  };
33
37
 
34
38
  } // namespace duckdb
@@ -29,6 +29,10 @@ public:
29
29
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
30
30
  LocalSourceState &lstate) const override;
31
31
 
32
+ bool IsSource() const override {
33
+ return true;
34
+ }
35
+
32
36
  public:
33
37
  // Sink interface
34
38
  unique_ptr<LocalSinkState> GetLocalSinkState(ExecutionContext &context) const override;
@@ -26,19 +26,17 @@ public:
26
26
  // Operator Interface
27
27
  unique_ptr<OperatorState> GetOperatorState(ExecutionContext &context) const override;
28
28
 
29
+ OrderPreservationType OperatorOrder() const override {
30
+ return OrderPreservationType::NO_ORDER;
31
+ }
29
32
  bool ParallelOperator() const override {
30
33
  return true;
31
34
  }
32
35
 
33
36
  protected:
34
- // CachingOperator Interface
35
37
  OperatorResultType ExecuteInternal(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
36
38
  GlobalOperatorState &gstate, OperatorState &state) const override;
37
39
 
38
- bool IsOrderPreserving() const override {
39
- return false;
40
- }
41
-
42
40
  public:
43
41
  // Sink Interface
44
42
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -51,6 +49,9 @@ public:
51
49
  bool ParallelSink() const override {
52
50
  return true;
53
51
  }
52
+ bool SinkOrderDependent() const override {
53
+ return false;
54
+ }
54
55
 
55
56
  public:
56
57
  void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) override;
@@ -46,7 +46,10 @@ public:
46
46
  bool ParallelSink() const override {
47
47
  return true;
48
48
  }
49
- bool IsOrderPreserving() const override {
49
+ OrderPreservationType SourceOrder() const override {
50
+ return OrderPreservationType::NO_ORDER;
51
+ }
52
+ bool SinkOrderDependent() const override {
50
53
  return false;
51
54
  }
52
55
  string ParamsToString() const override;
@@ -55,6 +55,9 @@ public:
55
55
  public:
56
56
  unique_ptr<OperatorState> GetOperatorState(ExecutionContext &context) const override;
57
57
 
58
+ OrderPreservationType OperatorOrder() const override {
59
+ return OrderPreservationType::NO_ORDER;
60
+ }
58
61
  bool ParallelOperator() const override {
59
62
  return true;
60
63
  }
@@ -63,10 +66,6 @@ protected:
63
66
  OperatorResultType ExecuteInternal(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
64
67
  GlobalOperatorState &gstate, OperatorState &state) const override;
65
68
 
66
- bool IsOrderPreserving() const override {
67
- return false;
68
- }
69
-
70
69
  public:
71
70
  void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) override;
72
71
  vector<const PhysicalOperator *> GetSources() const override;
@@ -37,7 +37,13 @@ public:
37
37
  void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) override;
38
38
  vector<const PhysicalOperator *> GetSources() const override;
39
39
 
40
- bool IsOrderPreserving() const override {
40
+ OrderPreservationType SourceOrder() const override {
41
+ return OrderPreservationType::NO_ORDER;
42
+ }
43
+ OrderPreservationType OperatorOrder() const override {
44
+ return OrderPreservationType::NO_ORDER;
45
+ }
46
+ bool SinkOrderDependent() const override {
41
47
  return false;
42
48
  }
43
49
  };
@@ -41,7 +41,7 @@ public:
41
41
  LocalSourceState &lstate) const override;
42
42
 
43
43
  bool IsSource() const override {
44
- return false;
44
+ return true;
45
45
  }
46
46
 
47
47
  bool ParallelSource() const override {
@@ -52,6 +52,10 @@ public:
52
52
  return true;
53
53
  }
54
54
 
55
+ OrderPreservationType SourceOrder() const override {
56
+ return OrderPreservationType::FIXED_ORDER;
57
+ }
58
+
55
59
  public:
56
60
  // Sink interface
57
61
  unique_ptr<LocalSinkState> GetLocalSinkState(ExecutionContext &context) const override;
@@ -68,6 +72,9 @@ public:
68
72
  bool ParallelSink() const override {
69
73
  return true;
70
74
  }
75
+ bool SinkOrderDependent() const override {
76
+ return false;
77
+ }
71
78
 
72
79
  public:
73
80
  string ParamsToString() const override;
@@ -34,6 +34,13 @@ public:
34
34
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
35
35
  LocalSourceState &lstate) const override;
36
36
 
37
+ bool IsSource() const override {
38
+ return true;
39
+ }
40
+ OrderPreservationType SourceOrder() const override {
41
+ return OrderPreservationType::FIXED_ORDER;
42
+ }
43
+
37
44
  public:
38
45
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
39
46
  DataChunk &input) const override;
@@ -46,6 +46,10 @@ public:
46
46
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
47
47
  LocalSourceState &lstate) const override;
48
48
 
49
+ bool IsSource() const override {
50
+ return true;
51
+ }
52
+
49
53
  public:
50
54
  // Sink interface
51
55
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -42,6 +42,10 @@ public:
42
42
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
43
43
  LocalSourceState &lstate) const override;
44
44
 
45
+ bool IsSource() const override {
46
+ return true;
47
+ }
48
+
45
49
  public:
46
50
  // Sink interface
47
51
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &gstate, LocalSinkState &lstate,
@@ -56,7 +60,7 @@ public:
56
60
  return true;
57
61
  }
58
62
 
59
- bool IsOrderDependent() const override {
63
+ bool SinkOrderDependent() const override {
60
64
  return true;
61
65
  }
62
66
 
@@ -36,6 +36,10 @@ public:
36
36
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
37
37
  LocalSourceState &lstate) const override;
38
38
 
39
+ bool IsSource() const override {
40
+ return true;
41
+ }
42
+
39
43
  public:
40
44
  // Sink interface
41
45
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -41,6 +41,10 @@ public:
41
41
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
42
42
  LocalSourceState &lstate) const override;
43
43
 
44
+ bool IsSource() const override {
45
+ return true;
46
+ }
47
+
44
48
  public:
45
49
  // Sink interface
46
50
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &gstate, LocalSinkState &lstate,
@@ -80,6 +80,10 @@ public:
80
80
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
81
81
  LocalSourceState &lstate) const override;
82
82
 
83
+ bool IsSource() const override {
84
+ return true;
85
+ }
86
+
83
87
  public:
84
88
  // Sink interface
85
89
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -98,6 +102,10 @@ public:
98
102
  return parallel;
99
103
  }
100
104
 
105
+ bool SinkOrderDependent() const override {
106
+ return true;
107
+ }
108
+
101
109
  public:
102
110
  static void GetInsertInfo(const BoundCreateTableInfo &info, vector<LogicalType> &insert_types,
103
111
  vector<unique_ptr<Expression>> &bound_defaults);
@@ -39,6 +39,10 @@ public:
39
39
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
40
40
  LocalSourceState &lstate) const override;
41
41
 
42
+ bool IsSource() const override {
43
+ return true;
44
+ }
45
+
42
46
  public:
43
47
  // Sink interface
44
48
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -33,6 +33,10 @@ public:
33
33
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
34
34
  LocalSourceState &lstate) const override;
35
35
 
36
+ bool IsSource() const override {
37
+ return true;
38
+ }
39
+
36
40
  public:
37
41
  void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline) override;
38
42
  };
@@ -25,5 +25,9 @@ public:
25
25
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
26
26
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
27
27
  LocalSourceState &lstate) const override;
28
+
29
+ bool IsSource() const override {
30
+ return true;
31
+ }
28
32
  };
29
33
  } // namespace duckdb
@@ -24,5 +24,9 @@ public:
24
24
  public:
25
25
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
26
26
  LocalSourceState &lstate) const override;
27
+
28
+ bool IsSource() const override {
29
+ return true;
30
+ }
27
31
  };
28
32
  } // namespace duckdb
@@ -39,6 +39,10 @@ public:
39
39
  LocalSourceState &lstate) const override;
40
40
 
41
41
  double GetProgress(ClientContext &context, GlobalSourceState &gstate) const override;
42
+
43
+ bool IsSource() const override {
44
+ return true;
45
+ }
42
46
  };
43
47
 
44
48
  } // namespace duckdb
@@ -60,6 +60,9 @@ public:
60
60
  idx_t GetBatchIndex(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
61
61
  LocalSourceState &lstate) const override;
62
62
 
63
+ bool IsSource() const override {
64
+ return true;
65
+ }
63
66
  bool ParallelSource() const override {
64
67
  return true;
65
68
  }
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -43,6 +43,10 @@ public:
43
43
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
44
44
  LocalSourceState &lstate) const override;
45
45
 
46
+ bool IsSource() const override {
47
+ return true;
48
+ }
49
+
46
50
  public:
47
51
  //! Sink interface, thread-local sink states
48
52
  unique_ptr<LocalSinkState> GetLocalSinkState(ExecutionContext &context) const override;
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -32,5 +32,9 @@ public:
32
32
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
33
33
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
34
34
  LocalSourceState &lstate) const override;
35
+
36
+ bool IsSource() const override {
37
+ return true;
38
+ }
35
39
  };
36
40
  } // namespace duckdb
@@ -29,6 +29,10 @@ public:
29
29
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
30
30
  LocalSourceState &lstate) const override;
31
31
 
32
+ bool IsSource() const override {
33
+ return true;
34
+ }
35
+
32
36
  public:
33
37
  // Sink interface
34
38
  unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -30,6 +30,10 @@ public:
30
30
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
31
31
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
32
32
  LocalSourceState &lstate) const override;
33
+
34
+ bool IsSource() const override {
35
+ return true;
36
+ }
33
37
  };
34
38
 
35
39
  } // namespace duckdb
@@ -31,6 +31,10 @@ public:
31
31
  unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
32
32
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
33
33
  LocalSourceState &lstate) const override;
34
+
35
+ bool IsSource() const override {
36
+ return true;
37
+ }
34
38
  };
35
39
 
36
40
  } // namespace duckdb
@@ -33,6 +33,10 @@ public:
33
33
  void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
34
34
  LocalSourceState &lstate) const override;
35
35
 
36
+ bool IsSource() const override {
37
+ return true;
38
+ }
39
+
36
40
  public:
37
41
  // Sink interface
38
42
  SinkResultType Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
@@ -16,6 +16,7 @@
16
16
  #include "duckdb/execution/execution_context.hpp"
17
17
  #include "duckdb/optimizer/join_order/join_node.hpp"
18
18
  #include "duckdb/execution/physical_operator_states.hpp"
19
+ #include "duckdb/common/enums/order_preservation_type.hpp"
19
20
 
20
21
  namespace duckdb {
21
22
  class Event;
@@ -74,12 +75,6 @@ public:
74
75
 
75
76
  virtual void Verify();
76
77
 
77
- //! Whether or not the operator depends on the order of the input chunks
78
- //! If this is set to true, we cannot do things like caching intermediate vectors
79
- virtual bool IsOrderDependent() const {
80
- return false;
81
- }
82
-
83
78
  public:
84
79
  // Operator interface
85
80
  virtual unique_ptr<OperatorState> GetOperatorState(ExecutionContext &context) const;
@@ -97,6 +92,11 @@ public:
97
92
  return false;
98
93
  }
99
94
 
95
+ //! The influence the operator has on order (insertion order means no influence)
96
+ virtual OrderPreservationType OperatorOrder() const {
97
+ return OrderPreservationType::INSERTION_ORDER;
98
+ }
99
+
100
100
  public:
101
101
  // Source interface
102
102
  virtual unique_ptr<LocalSourceState> GetLocalSourceState(ExecutionContext &context,
@@ -119,8 +119,9 @@ public:
119
119
  return false;
120
120
  }
121
121
 
122
- virtual bool IsOrderPreserving() const {
123
- return true;
122
+ //! The type of order emitted by the operator (as a source)
123
+ virtual OrderPreservationType SourceOrder() const {
124
+ return OrderPreservationType::INSERTION_ORDER;
124
125
  }
125
126
 
126
127
  //! Returns the current progress percentage, or a negative value if progress bars are not supported
@@ -161,11 +162,16 @@ public:
161
162
  return false;
162
163
  }
163
164
 
165
+ //! Whether or not the sink operator depends on the order of the input chunks
166
+ //! If this is set to true, we cannot do things like caching intermediate vectors
167
+ virtual bool SinkOrderDependent() const {
168
+ return false;
169
+ }
170
+
164
171
  public:
165
172
  // Pipeline construction
166
173
  virtual vector<const PhysicalOperator *> GetSources() const;
167
174
  bool AllSourcesSupportBatchIndex() const;
168
- virtual bool AllOperatorsPreserveOrder() const;
169
175
 
170
176
  virtual void BuildPipelines(Pipeline &current, MetaPipeline &meta_pipeline);
171
177
 
@@ -90,7 +90,7 @@ public:
90
90
  return source;
91
91
  }
92
92
 
93
- //! Returns whether any of the operators in the pipeline care about preserving insertion order
93
+ //! Returns whether any of the operators in the pipeline care about preserving order
94
94
  bool IsOrderDependent() const;
95
95
 
96
96
  private:
@@ -78,6 +78,13 @@
78
78
  #include "inet-extension.hpp"
79
79
  #endif
80
80
 
81
+ #if defined(BUILD_AUTOCOMPLETE_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
82
+ #define AUTOCOMPLETE_STATICALLY_LOADED true
83
+ #include "sql_auto_complete-extension.hpp"
84
+ #else
85
+ #define AUTOCOMPLETE_STATICALLY_LOADED false
86
+ #endif
87
+
81
88
  // Load the generated header file containing our list of extension headers
82
89
  #if defined(OOTE_HEADERS_AVAILABLE) && OOTE_HEADERS_AVAILABLE
83
90
  #include "extension_oote_loader.hpp"
@@ -97,6 +104,7 @@ static DefaultExtension internal_extensions[] = {
97
104
  {"httpfs", "Adds support for reading and writing files over a HTTP(S) connection", HTTPFS_STATICALLY_LOADED},
98
105
  {"json", "Adds support for JSON operations", JSON_STATICALLY_LOADED},
99
106
  {"jemalloc", "Overwrites system allocator with JEMalloc", JEMALLOC_STATICALLY_LOADED},
107
+ {"autocomplete", "Add supports for autocomplete in the shell", AUTOCOMPLETE_STATICALLY_LOADED},
100
108
  {"motherduck", "Enables motherduck integration with the system", false},
101
109
  {"sqlite_scanner", "Adds support for reading SQLite database files", false},
102
110
  {"postgres_scanner", "Adds support for reading from a Postgres database", false},
@@ -134,8 +142,8 @@ bool ExtensionHelper::AllowAutoInstall(const string &extension) {
134
142
  // Load Statically Compiled Extension
135
143
  //===--------------------------------------------------------------------===//
136
144
  void ExtensionHelper::LoadAllExtensions(DuckDB &db) {
137
- unordered_set<string> extensions {"parquet", "icu", "tpch", "tpcds", "fts", "httpfs",
138
- "visualizer", "json", "excel", "sqlsmith", "inet", "jemalloc"};
145
+ unordered_set<string> extensions {"parquet", "icu", "tpch", "tpcds", "fts", "httpfs", "visualizer",
146
+ "json", "excel", "sqlsmith", "inet", "jemalloc", "autocomplete"};
139
147
  for (auto &ext : extensions) {
140
148
  LoadExtensionInternal(db, ext, true);
141
149
  }
@@ -244,6 +252,13 @@ ExtensionLoadResult ExtensionHelper::LoadExtensionInternal(DuckDB &db, const std
244
252
  #else
245
253
  // jemalloc extension required but not build: skip this test
246
254
  return ExtensionLoadResult::NOT_LOADED;
255
+ #endif
256
+ } else if (extension == "autocomplete") {
257
+ #if defined(BUILD_AUTOCOMPLETE_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
258
+ db.LoadExtension<SQLAutoCompleteExtension>();
259
+ #else
260
+ // autocomplete extension required but not build: skip this test
261
+ return ExtensionLoadResult::NOT_LOADED;
247
262
  #endif
248
263
  } else if (extension == "inet") {
249
264
  #if defined(BUILD_INET_EXTENSION) && !defined(DISABLE_BUILTIN_EXTENSIONS)
@@ -98,20 +98,29 @@ bool Pipeline::ScheduleParallel(shared_ptr<Event> &event) {
98
98
 
99
99
  bool Pipeline::IsOrderDependent() const {
100
100
  auto &config = DBConfig::GetConfig(executor.context);
101
- if (!config.options.preserve_insertion_order) {
102
- return false;
103
- }
104
- if (sink && sink->IsOrderDependent()) {
105
- return true;
106
- }
107
- if (source && source->IsOrderDependent()) {
108
- return true;
101
+ if (source) {
102
+ auto source_order = source->SourceOrder();
103
+ if (source_order == OrderPreservationType::FIXED_ORDER) {
104
+ return true;
105
+ }
106
+ if (source_order == OrderPreservationType::NO_ORDER) {
107
+ return false;
108
+ }
109
109
  }
110
110
  for (auto &op : operators) {
111
- if (op->IsOrderDependent()) {
111
+ if (op->OperatorOrder() == OrderPreservationType::NO_ORDER) {
112
+ return false;
113
+ }
114
+ if (op->OperatorOrder() == OrderPreservationType::FIXED_ORDER) {
112
115
  return true;
113
116
  }
114
117
  }
118
+ if (!config.options.preserve_insertion_order) {
119
+ return false;
120
+ }
121
+ if (sink && sink->SinkOrderDependent()) {
122
+ return true;
123
+ }
115
124
  return false;
116
125
  }
117
126
 
@@ -148,6 +157,9 @@ bool Pipeline::LaunchScanTasks(shared_ptr<Event> &event, idx_t max_threads) {
148
157
 
149
158
  void Pipeline::ResetSink() {
150
159
  if (sink) {
160
+ if (!sink->IsSink()) {
161
+ throw InternalException("Sink of pipeline does not have IsSink set");
162
+ }
151
163
  lock_guard<mutex> guard(sink->lock);
152
164
  if (!sink->sink_state) {
153
165
  sink->sink_state = sink->GetGlobalSinkState(GetClientContext());
@@ -172,6 +184,9 @@ void Pipeline::Reset() {
172
184
  }
173
185
 
174
186
  void Pipeline::ResetSource(bool force) {
187
+ if (source && !source->IsSource()) {
188
+ throw InternalException("Source of pipeline does not have IsSource set");
189
+ }
175
190
  if (force || !source_state) {
176
191
  source_state = source->GetGlobalSourceState(GetClientContext());
177
192
  }