duckdb 0.7.2-dev1034.0 → 0.7.2-dev1138.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.
- package/package.json +1 -1
- package/src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp +1 -1
- package/src/duckdb/src/common/hive_partitioning.cpp +3 -1
- package/src/duckdb/src/common/progress_bar/progress_bar.cpp +7 -0
- package/src/duckdb/src/common/serializer/enum_serializer.cpp +6 -6
- package/src/duckdb/src/common/sort/comparators.cpp +14 -5
- package/src/duckdb/src/common/types/interval.cpp +0 -41
- package/src/duckdb/src/common/types/list_segment.cpp +658 -0
- package/src/duckdb/src/common/types/string_heap.cpp +1 -1
- package/src/duckdb/src/common/types/string_type.cpp +1 -1
- package/src/duckdb/src/common/types/vector.cpp +1 -1
- package/src/duckdb/src/common/value_operations/comparison_operations.cpp +14 -22
- package/src/duckdb/src/common/vector_operations/comparison_operators.cpp +10 -10
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +11 -10
- package/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +2 -2
- package/src/duckdb/src/execution/index/art/art.cpp +13 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +2 -0
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +1 -0
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +0 -3
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +5 -1
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +18 -5
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +3 -0
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +2 -1
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -3
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +1 -0
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +0 -4
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -0
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +2 -1
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +1 -0
- package/src/duckdb/src/function/aggregate/nested/list.cpp +6 -712
- package/src/duckdb/src/function/scalar/list/list_sort.cpp +25 -18
- package/src/duckdb/src/function/table/read_csv.cpp +5 -0
- package/src/duckdb/src/function/table/table_scan.cpp +8 -11
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/helper.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/operator/comparison_operators.hpp +45 -149
- package/src/duckdb/src/include/duckdb/common/progress_bar/progress_bar.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/types/interval.hpp +39 -3
- package/src/duckdb/src/include/duckdb/common/types/list_segment.hpp +70 -0
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +73 -3
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +1 -12
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +0 -2
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/index.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +18 -7
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +0 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_segment_tree.hpp +18 -0
- package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +0 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +35 -43
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +18 -5
- package/src/duckdb/src/include/duckdb/storage/table/row_group_segment_tree.hpp +2 -4
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +12 -29
- package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +2 -3
- package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +11 -1
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +0 -4
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +4 -1
- package/src/duckdb/src/include/duckdb.h +21 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +23 -0
- package/src/duckdb/src/main/settings/settings.cpp +20 -8
- package/src/duckdb/src/optimizer/filter_combiner.cpp +2 -5
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +2 -0
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +1 -0
- package/src/duckdb/src/parallel/meta_pipeline.cpp +0 -3
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +22 -0
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -0
- package/src/duckdb/src/storage/compression/bitpacking.cpp +1 -1
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +2 -1
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +1 -1
- package/src/duckdb/src/storage/compression/rle.cpp +1 -0
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +1 -1
- package/src/duckdb/src/storage/data_table.cpp +3 -3
- package/src/duckdb/src/storage/local_storage.cpp +7 -0
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/column_data.cpp +75 -18
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +3 -1
- package/src/duckdb/src/storage/table/column_segment.cpp +17 -31
- package/src/duckdb/src/storage/table/list_column_data.cpp +9 -12
- package/src/duckdb/src/storage/table/row_group.cpp +200 -136
- package/src/duckdb/src/storage/table/row_group_collection.cpp +75 -45
- package/src/duckdb/src/storage/table/scan_state.cpp +31 -38
- package/src/duckdb/src/storage/table/standard_column_data.cpp +4 -6
- package/src/duckdb/src/storage/table/struct_column_data.cpp +11 -18
- package/src/duckdb/src/storage/table/update_segment.cpp +3 -0
- package/src/duckdb/ub_src_common_types.cpp +2 -0
|
@@ -18,8 +18,6 @@ class SegmentBase {
|
|
|
18
18
|
public:
|
|
19
19
|
SegmentBase(idx_t start, idx_t count) : start(start), count(count), next(nullptr) {
|
|
20
20
|
}
|
|
21
|
-
virtual ~SegmentBase() {
|
|
22
|
-
}
|
|
23
21
|
T *Next() {
|
|
24
22
|
#ifndef DUCKDB_R_BUILD
|
|
25
23
|
return next.load();
|
|
@@ -33,12 +31,13 @@ public:
|
|
|
33
31
|
//! The amount of entries in this storage chunk
|
|
34
32
|
atomic<idx_t> count;
|
|
35
33
|
//! The next segment after this one
|
|
36
|
-
|
|
37
34
|
#ifndef DUCKDB_R_BUILD
|
|
38
35
|
atomic<T *> next;
|
|
39
36
|
#else
|
|
40
37
|
T *next;
|
|
41
38
|
#endif
|
|
39
|
+
//! The index within the segment tree
|
|
40
|
+
idx_t index;
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
} // namespace duckdb
|
|
@@ -56,7 +56,7 @@ public:
|
|
|
56
56
|
if (nodes.empty()) {
|
|
57
57
|
LoadNextSegment(l);
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return GetRootSegmentInternal();
|
|
60
60
|
}
|
|
61
61
|
//! Obtains ownership of the data of the segment tree
|
|
62
62
|
vector<SegmentNode<T>> MoveSegments(SegmentLock &l) {
|
|
@@ -258,6 +258,10 @@ private:
|
|
|
258
258
|
mutex node_lock;
|
|
259
259
|
|
|
260
260
|
private:
|
|
261
|
+
T *GetRootSegmentInternal() {
|
|
262
|
+
return nodes.empty() ? nullptr : nodes[0].node.get();
|
|
263
|
+
}
|
|
264
|
+
|
|
261
265
|
class SegmentIterationHelper {
|
|
262
266
|
public:
|
|
263
267
|
explicit SegmentIterationHelper(SegmentTree &tree) : tree(tree) {
|
|
@@ -304,6 +308,9 @@ private:
|
|
|
304
308
|
|
|
305
309
|
//! Load the next segment, if there are any left to load
|
|
306
310
|
bool LoadNextSegment(SegmentLock &l) {
|
|
311
|
+
if (!SUPPORTS_LAZY_LOADING) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
307
314
|
if (finished_loading) {
|
|
308
315
|
return false;
|
|
309
316
|
}
|
|
@@ -317,6 +324,9 @@ private:
|
|
|
317
324
|
|
|
318
325
|
//! Load all segments, if there are any left to load
|
|
319
326
|
void LoadAllSegments(SegmentLock &l) {
|
|
327
|
+
if (!SUPPORTS_LAZY_LOADING) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
320
330
|
while (LoadNextSegment(l))
|
|
321
331
|
;
|
|
322
332
|
}
|
|
@@ -59,10 +59,6 @@ public:
|
|
|
59
59
|
void GetStorageInfo(idx_t row_group_index, vector<idx_t> col_path, TableStorageInfo &result) override;
|
|
60
60
|
|
|
61
61
|
void Verify(RowGroup &parent) override;
|
|
62
|
-
|
|
63
|
-
private:
|
|
64
|
-
template <bool SCAN_COMMITTED, bool ALLOW_UPDATES>
|
|
65
|
-
void TemplatedScan(Transaction *transaction, ColumnScanState &state, Vector &result);
|
|
66
62
|
};
|
|
67
63
|
|
|
68
64
|
} // namespace duckdb
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
#pragma once
|
|
10
10
|
|
|
11
11
|
#include "duckdb/storage/table/row_group_collection.hpp"
|
|
12
|
-
#include "duckdb/storage/table/scan_state.hpp"
|
|
13
12
|
#include "duckdb/storage/table/table_index_list.hpp"
|
|
14
13
|
#include "duckdb/storage/table/table_statistics.hpp"
|
|
15
14
|
|
|
@@ -18,6 +17,7 @@ class AttachedDatabase;
|
|
|
18
17
|
class DataTable;
|
|
19
18
|
class Transaction;
|
|
20
19
|
class WriteAheadLog;
|
|
20
|
+
struct LocalAppendState;
|
|
21
21
|
struct TableAppendState;
|
|
22
22
|
|
|
23
23
|
class OptimisticDataWriter {
|
|
@@ -118,6 +118,9 @@ public:
|
|
|
118
118
|
|
|
119
119
|
public:
|
|
120
120
|
struct CommitState {
|
|
121
|
+
CommitState();
|
|
122
|
+
~CommitState();
|
|
123
|
+
|
|
121
124
|
unordered_map<DataTable *, unique_ptr<TableAppendState>> append_states;
|
|
122
125
|
};
|
|
123
126
|
|
|
@@ -1710,6 +1710,16 @@ Adds a parameter to the table function.
|
|
|
1710
1710
|
*/
|
|
1711
1711
|
DUCKDB_API void duckdb_table_function_add_parameter(duckdb_table_function table_function, duckdb_logical_type type);
|
|
1712
1712
|
|
|
1713
|
+
/*!
|
|
1714
|
+
Adds a named parameter to the table function.
|
|
1715
|
+
|
|
1716
|
+
* table_function: The table function
|
|
1717
|
+
* name: The name of the parameter
|
|
1718
|
+
* type: The type of the parameter to add.
|
|
1719
|
+
*/
|
|
1720
|
+
DUCKDB_API void duckdb_table_function_add_named_parameter(duckdb_table_function table_function, const char *name,
|
|
1721
|
+
duckdb_logical_type type);
|
|
1722
|
+
|
|
1713
1723
|
/*!
|
|
1714
1724
|
Assigns extra information to the table function that can be fetched during binding, etc.
|
|
1715
1725
|
|
|
@@ -1818,6 +1828,17 @@ The result must be destroyed with `duckdb_destroy_value`.
|
|
|
1818
1828
|
*/
|
|
1819
1829
|
DUCKDB_API duckdb_value duckdb_bind_get_parameter(duckdb_bind_info info, idx_t index);
|
|
1820
1830
|
|
|
1831
|
+
/*!
|
|
1832
|
+
Retrieves a named parameter with the given name.
|
|
1833
|
+
|
|
1834
|
+
The result must be destroyed with `duckdb_destroy_value`.
|
|
1835
|
+
|
|
1836
|
+
* info: The info object
|
|
1837
|
+
* name: The name of the parameter
|
|
1838
|
+
* returns: The value of the parameter. Must be destroyed with `duckdb_destroy_value`.
|
|
1839
|
+
*/
|
|
1840
|
+
DUCKDB_API duckdb_value duckdb_bind_get_named_parameter(duckdb_bind_info info, const char *name);
|
|
1841
|
+
|
|
1821
1842
|
/*!
|
|
1822
1843
|
Sets the user-provided bind data in the bind object. This object can be retrieved again during execution.
|
|
1823
1844
|
|
|
@@ -208,6 +208,16 @@ void duckdb_table_function_add_parameter(duckdb_table_function function, duckdb_
|
|
|
208
208
|
tf->arguments.push_back(*logical_type);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
void duckdb_table_function_add_named_parameter(duckdb_table_function function, const char *name,
|
|
212
|
+
duckdb_logical_type type) {
|
|
213
|
+
if (!function || !type) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
auto tf = (duckdb::TableFunction *)function;
|
|
217
|
+
auto logical_type = (duckdb::LogicalType *)type;
|
|
218
|
+
tf->named_parameters.insert({name, *logical_type});
|
|
219
|
+
}
|
|
220
|
+
|
|
211
221
|
void duckdb_table_function_set_extra_info(duckdb_table_function function, void *extra_info,
|
|
212
222
|
duckdb_delete_callback_t destroy) {
|
|
213
223
|
if (!function) {
|
|
@@ -319,6 +329,19 @@ duckdb_value duckdb_bind_get_parameter(duckdb_bind_info info, idx_t index) {
|
|
|
319
329
|
return reinterpret_cast<duckdb_value>(new duckdb::Value(bind_info->input.inputs[index]));
|
|
320
330
|
}
|
|
321
331
|
|
|
332
|
+
duckdb_value duckdb_bind_get_named_parameter(duckdb_bind_info info, const char *name) {
|
|
333
|
+
if (!info || !name) {
|
|
334
|
+
return nullptr;
|
|
335
|
+
}
|
|
336
|
+
auto bind_info = (duckdb::CTableInternalBindInfo *)info;
|
|
337
|
+
auto t = bind_info->input.named_parameters.find(name);
|
|
338
|
+
if (t == bind_info->input.named_parameters.end()) {
|
|
339
|
+
return nullptr;
|
|
340
|
+
} else {
|
|
341
|
+
return reinterpret_cast<duckdb_value>(new duckdb::Value(t->second));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
322
345
|
void duckdb_bind_set_bind_data(duckdb_bind_info info, void *bind_data, duckdb_delete_callback_t destroy) {
|
|
323
346
|
if (!info) {
|
|
324
347
|
return;
|
|
@@ -454,11 +454,15 @@ Value CustomExtensionRepository::GetSetting(ClientContext &context) {
|
|
|
454
454
|
//===--------------------------------------------------------------------===//
|
|
455
455
|
|
|
456
456
|
void EnableProgressBarSetting::ResetLocal(ClientContext &context) {
|
|
457
|
-
ClientConfig::GetConfig(context)
|
|
457
|
+
auto &config = ClientConfig::GetConfig(context);
|
|
458
|
+
ProgressBar::SystemOverrideCheck(config);
|
|
459
|
+
config.enable_progress_bar = ClientConfig().enable_progress_bar;
|
|
458
460
|
}
|
|
459
461
|
|
|
460
462
|
void EnableProgressBarSetting::SetLocal(ClientContext &context, const Value &input) {
|
|
461
|
-
ClientConfig::GetConfig(context)
|
|
463
|
+
auto &config = ClientConfig::GetConfig(context);
|
|
464
|
+
ProgressBar::SystemOverrideCheck(config);
|
|
465
|
+
config.enable_progress_bar = input.GetValue<bool>();
|
|
462
466
|
}
|
|
463
467
|
|
|
464
468
|
Value EnableProgressBarSetting::GetSetting(ClientContext &context) {
|
|
@@ -469,11 +473,15 @@ Value EnableProgressBarSetting::GetSetting(ClientContext &context) {
|
|
|
469
473
|
// Enable Progress Bar Print
|
|
470
474
|
//===--------------------------------------------------------------------===//
|
|
471
475
|
void EnableProgressBarPrintSetting::SetLocal(ClientContext &context, const Value &input) {
|
|
472
|
-
ClientConfig::GetConfig(context)
|
|
476
|
+
auto &config = ClientConfig::GetConfig(context);
|
|
477
|
+
ProgressBar::SystemOverrideCheck(config);
|
|
478
|
+
config.print_progress_bar = input.GetValue<bool>();
|
|
473
479
|
}
|
|
474
480
|
|
|
475
481
|
void EnableProgressBarPrintSetting::ResetLocal(ClientContext &context) {
|
|
476
|
-
ClientConfig::GetConfig(context)
|
|
482
|
+
auto &config = ClientConfig::GetConfig(context);
|
|
483
|
+
ProgressBar::SystemOverrideCheck(config);
|
|
484
|
+
config.print_progress_bar = ClientConfig().print_progress_bar;
|
|
477
485
|
}
|
|
478
486
|
|
|
479
487
|
Value EnableProgressBarPrintSetting::GetSetting(ClientContext &context) {
|
|
@@ -878,13 +886,17 @@ Value ProfilingModeSetting::GetSetting(ClientContext &context) {
|
|
|
878
886
|
//===--------------------------------------------------------------------===//
|
|
879
887
|
|
|
880
888
|
void ProgressBarTimeSetting::ResetLocal(ClientContext &context) {
|
|
881
|
-
ClientConfig::GetConfig(context)
|
|
882
|
-
|
|
889
|
+
auto &config = ClientConfig::GetConfig(context);
|
|
890
|
+
ProgressBar::SystemOverrideCheck(config);
|
|
891
|
+
config.wait_time = ClientConfig().wait_time;
|
|
892
|
+
config.enable_progress_bar = ClientConfig().enable_progress_bar;
|
|
883
893
|
}
|
|
884
894
|
|
|
885
895
|
void ProgressBarTimeSetting::SetLocal(ClientContext &context, const Value &input) {
|
|
886
|
-
ClientConfig::GetConfig(context)
|
|
887
|
-
|
|
896
|
+
auto &config = ClientConfig::GetConfig(context);
|
|
897
|
+
ProgressBar::SystemOverrideCheck(config);
|
|
898
|
+
config.wait_time = input.GetValue<int32_t>();
|
|
899
|
+
config.enable_progress_bar = true;
|
|
888
900
|
}
|
|
889
901
|
|
|
890
902
|
Value ProgressBarTimeSetting::GetSetting(ClientContext &context) {
|
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
#include "duckdb/execution/expression_executor.hpp"
|
|
4
4
|
#include "duckdb/planner/expression.hpp"
|
|
5
|
-
#include "duckdb/planner/expression_iterator.hpp"
|
|
6
5
|
#include "duckdb/planner/expression/bound_between_expression.hpp"
|
|
6
|
+
#include "duckdb/planner/expression/bound_cast_expression.hpp"
|
|
7
7
|
#include "duckdb/planner/expression/bound_columnref_expression.hpp"
|
|
8
8
|
#include "duckdb/planner/expression/bound_comparison_expression.hpp"
|
|
9
9
|
#include "duckdb/planner/expression/bound_conjunction_expression.hpp"
|
|
10
10
|
#include "duckdb/planner/expression/bound_constant_expression.hpp"
|
|
11
11
|
#include "duckdb/planner/expression/bound_function_expression.hpp"
|
|
12
|
-
#include "duckdb/planner/
|
|
13
|
-
#include "duckdb/planner/operator/logical_filter.hpp"
|
|
12
|
+
#include "duckdb/planner/expression/bound_operator_expression.hpp"
|
|
14
13
|
#include "duckdb/planner/table_filter.hpp"
|
|
15
14
|
#include "duckdb/planner/filter/constant_filter.hpp"
|
|
16
15
|
#include "duckdb/planner/filter/null_filter.hpp"
|
|
17
16
|
#include "duckdb/optimizer/optimizer.hpp"
|
|
18
|
-
#include "duckdb/common/operator/cast_operators.hpp"
|
|
19
|
-
#include "duckdb/planner/filter/conjunction_filter.hpp"
|
|
20
17
|
|
|
21
18
|
namespace duckdb {
|
|
22
19
|
|
|
@@ -156,9 +156,6 @@ Pipeline *MetaPipeline::CreateUnionPipeline(Pipeline ¤t, bool order_matter
|
|
|
156
156
|
void MetaPipeline::CreateChildPipeline(Pipeline ¤t, PhysicalOperator *op, Pipeline *last_pipeline) {
|
|
157
157
|
// rule 2: 'current' must be fully built (down to the source) before creating the child pipeline
|
|
158
158
|
D_ASSERT(current.source);
|
|
159
|
-
if (HasRecursiveCTE()) {
|
|
160
|
-
throw NotImplementedException("Child pipelines are not supported in recursive CTEs yet");
|
|
161
|
-
}
|
|
162
159
|
|
|
163
160
|
// create the child pipeline (same batch index)
|
|
164
161
|
pipelines.emplace_back(state.CreateChildPipeline(executor, current, op));
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
#include "duckdb/common/serializer/enum_serializer.hpp"
|
|
1
2
|
#include "duckdb/common/string_util.hpp"
|
|
2
3
|
#include "duckdb/common/to_string.hpp"
|
|
3
4
|
#include "duckdb/parser/expression/case_expression.hpp"
|
|
4
5
|
#include "duckdb/parser/expression/cast_expression.hpp"
|
|
6
|
+
#include "duckdb/parser/expression/constant_expression.hpp"
|
|
5
7
|
#include "duckdb/parser/expression/function_expression.hpp"
|
|
6
8
|
|
|
7
9
|
#include "duckdb/parser/expression/operator_expression.hpp"
|
|
@@ -310,6 +312,26 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
|
310
312
|
coalesce_op->children.push_back(std::move(children[0]));
|
|
311
313
|
coalesce_op->children.push_back(std::move(children[1]));
|
|
312
314
|
return std::move(coalesce_op);
|
|
315
|
+
} else if (lowercase_name == "list" && order_bys->orders.size() == 1) {
|
|
316
|
+
// list(expr ORDER BY expr <sense> <nulls>) => list_sort(list(expr), <sense>, <nulls>)
|
|
317
|
+
if (children.size() != 1) {
|
|
318
|
+
throw ParserException("Wrong number of arguments to LIST.");
|
|
319
|
+
}
|
|
320
|
+
auto arg_expr = children[0].get();
|
|
321
|
+
auto &order_by = order_bys->orders[0];
|
|
322
|
+
if (arg_expr->Equals(order_by.expression.get())) {
|
|
323
|
+
auto sense = make_unique<ConstantExpression>(EnumSerializer::EnumToString(order_by.type));
|
|
324
|
+
auto nulls = make_unique<ConstantExpression>(EnumSerializer::EnumToString(order_by.null_order));
|
|
325
|
+
order_bys = nullptr;
|
|
326
|
+
auto unordered = make_unique<FunctionExpression>(
|
|
327
|
+
catalog, schema, lowercase_name.c_str(), std::move(children), std::move(filter_expr),
|
|
328
|
+
std::move(order_bys), root->agg_distinct, false, root->export_state);
|
|
329
|
+
lowercase_name = "list_sort";
|
|
330
|
+
children.clear();
|
|
331
|
+
children.emplace_back(std::move(unordered));
|
|
332
|
+
children.emplace_back(std::move(sense));
|
|
333
|
+
children.emplace_back(std::move(nulls));
|
|
334
|
+
}
|
|
313
335
|
}
|
|
314
336
|
|
|
315
337
|
auto function = make_unique<FunctionExpression>(std::move(catalog), std::move(schema), lowercase_name.c_str(),
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include "duckdb/planner/binder.hpp"
|
|
4
4
|
#include "duckdb/planner/constraints/list.hpp"
|
|
5
5
|
#include "duckdb/planner/expression/bound_constant_expression.hpp"
|
|
6
|
+
#include "duckdb/planner/expression/bound_function_expression.hpp"
|
|
6
7
|
#include "duckdb/planner/expression_binder/check_binder.hpp"
|
|
7
8
|
#include "duckdb/planner/expression_binder/constant_binder.hpp"
|
|
8
9
|
#include "duckdb/planner/parsed_data/bound_create_table_info.hpp"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "duckdb/common/bitpacking.hpp"
|
|
2
2
|
|
|
3
3
|
#include "duckdb/common/limits.hpp"
|
|
4
|
-
#include "duckdb/common/types/null_value.hpp"
|
|
5
4
|
#include "duckdb/function/compression/compression.hpp"
|
|
6
5
|
#include "duckdb/function/compression_function.hpp"
|
|
7
6
|
#include "duckdb/main/config.hpp"
|
|
@@ -11,6 +10,7 @@
|
|
|
11
10
|
#include "duckdb/storage/table/column_segment.hpp"
|
|
12
11
|
#include "duckdb/common/operator/subtract.hpp"
|
|
13
12
|
#include "duckdb/storage/compression/bitpacking.hpp"
|
|
13
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
14
14
|
|
|
15
15
|
#include <functional>
|
|
16
16
|
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#include "duckdb/storage/table/append_state.hpp"
|
|
10
10
|
#include "duckdb/storage/table/column_data_checkpointer.hpp"
|
|
11
11
|
#include "duckdb/storage/table/column_segment.hpp"
|
|
12
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
12
13
|
|
|
13
14
|
namespace duckdb {
|
|
14
15
|
|
|
@@ -64,7 +65,7 @@ void UncompressedCompressState::CreateEmptySegment(idx_t row_start) {
|
|
|
64
65
|
auto compressed_segment = ColumnSegment::CreateTransientSegment(db, type, row_start);
|
|
65
66
|
if (type.InternalType() == PhysicalType::VARCHAR) {
|
|
66
67
|
auto &state = (UncompressedStringSegmentState &)*compressed_segment->GetSegmentState();
|
|
67
|
-
state.overflow_writer = make_unique<WriteOverflowStringsToDisk>(checkpointer.GetColumnData().
|
|
68
|
+
state.overflow_writer = make_unique<WriteOverflowStringsToDisk>(checkpointer.GetColumnData().GetBlockManager());
|
|
68
69
|
}
|
|
69
70
|
current_segment = std::move(compressed_segment);
|
|
70
71
|
current_segment->InitializeAppend(append_state);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#include "duckdb/function/compression/compression.hpp"
|
|
2
|
-
#include "duckdb/storage/buffer_manager.hpp"
|
|
3
2
|
#include "duckdb/common/types/vector.hpp"
|
|
4
3
|
|
|
5
4
|
#include "duckdb/storage/table/column_segment.hpp"
|
|
6
5
|
#include "duckdb/function/compression_function.hpp"
|
|
7
6
|
#include "duckdb/storage/segment/uncompressed.hpp"
|
|
7
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
8
8
|
|
|
9
9
|
namespace duckdb {
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
#include "duckdb/common/types/null_value.hpp"
|
|
7
7
|
#include "duckdb/storage/table/column_segment.hpp"
|
|
8
8
|
#include "duckdb/function/compression_function.hpp"
|
|
9
|
-
#include "duckdb/
|
|
9
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
10
10
|
|
|
11
11
|
namespace duckdb {
|
|
12
12
|
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
#include "duckdb/common/exception.hpp"
|
|
6
6
|
#include "duckdb/common/helper.hpp"
|
|
7
7
|
#include "duckdb/common/vector_operations/vector_operations.hpp"
|
|
8
|
-
#include "duckdb/common/sort/sort.hpp"
|
|
9
8
|
#include "duckdb/execution/expression_executor.hpp"
|
|
10
9
|
#include "duckdb/main/client_context.hpp"
|
|
11
10
|
#include "duckdb/parser/constraints/list.hpp"
|
|
@@ -23,6 +22,8 @@
|
|
|
23
22
|
#include "duckdb/main/attached_database.hpp"
|
|
24
23
|
#include "duckdb/common/types/conflict_manager.hpp"
|
|
25
24
|
#include "duckdb/common/types/constraint_conflict_info.hpp"
|
|
25
|
+
#include "duckdb/storage/table/append_state.hpp"
|
|
26
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
26
27
|
|
|
27
28
|
namespace duckdb {
|
|
28
29
|
|
|
@@ -728,8 +729,7 @@ void DataTable::ScanTableSegment(idx_t row_start, idx_t count, const std::functi
|
|
|
728
729
|
CreateIndexScanState state;
|
|
729
730
|
|
|
730
731
|
InitializeScanWithOffset(state, column_ids, row_start, row_start + count);
|
|
731
|
-
auto row_start_aligned = state.table_state.
|
|
732
|
-
state.table_state.row_group_state.vector_index * STANDARD_VECTOR_SIZE;
|
|
732
|
+
auto row_start_aligned = state.table_state.row_group->start + state.table_state.vector_index * STANDARD_VECTOR_SIZE;
|
|
733
733
|
|
|
734
734
|
idx_t current_row = row_start_aligned;
|
|
735
735
|
while (current_row < end) {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
#include "duckdb/storage/table/column_checkpoint_state.hpp"
|
|
12
12
|
#include "duckdb/storage/table/column_segment.hpp"
|
|
13
13
|
#include "duckdb/storage/table_io_manager.hpp"
|
|
14
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
14
15
|
|
|
15
16
|
namespace duckdb {
|
|
16
17
|
|
|
@@ -355,6 +356,12 @@ LocalStorage::LocalStorage(ClientContext &context, DuckTransaction &transaction)
|
|
|
355
356
|
: context(context), transaction(transaction) {
|
|
356
357
|
}
|
|
357
358
|
|
|
359
|
+
LocalStorage::CommitState::CommitState() {
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
LocalStorage::CommitState::~CommitState() {
|
|
363
|
+
}
|
|
364
|
+
|
|
358
365
|
LocalStorage &LocalStorage::Get(DuckTransaction &transaction) {
|
|
359
366
|
return transaction.GetLocalStorage();
|
|
360
367
|
}
|
|
@@ -10,27 +10,35 @@
|
|
|
10
10
|
#include "duckdb/storage/table/column_data_checkpointer.hpp"
|
|
11
11
|
#include "duckdb/storage/table/list_column_data.hpp"
|
|
12
12
|
#include "duckdb/storage/table/standard_column_data.hpp"
|
|
13
|
-
#include "duckdb/transaction/transaction.hpp"
|
|
14
13
|
|
|
15
14
|
#include "duckdb/storage/table/struct_column_data.hpp"
|
|
16
15
|
#include "duckdb/storage/table/update_segment.hpp"
|
|
17
16
|
#include "duckdb/storage/table_storage_info.hpp"
|
|
17
|
+
#include "duckdb/storage/table/append_state.hpp"
|
|
18
|
+
#include "duckdb/storage/table/scan_state.hpp"
|
|
18
19
|
#include "duckdb/main/attached_database.hpp"
|
|
19
20
|
|
|
20
21
|
namespace duckdb {
|
|
21
22
|
|
|
22
23
|
ColumnData::ColumnData(BlockManager &block_manager, DataTableInfo &info, idx_t column_index, idx_t start_row,
|
|
23
|
-
LogicalType
|
|
24
|
-
:
|
|
25
|
-
parent(parent), version(0) {
|
|
24
|
+
LogicalType type_p, ColumnData *parent)
|
|
25
|
+
: start(start_row), count(0), block_manager(block_manager), info(info), column_index(column_index),
|
|
26
|
+
type(std::move(type_p)), parent(parent), version(0) {
|
|
27
|
+
if (!parent) {
|
|
28
|
+
stats = make_unique<SegmentStatistics>(type);
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
ColumnData::ColumnData(ColumnData &other, idx_t start, ColumnData *parent)
|
|
29
|
-
:
|
|
30
|
-
type(std::move(other.type)), parent(parent),
|
|
33
|
+
: start(start), count(other.count), block_manager(other.block_manager), info(other.info),
|
|
34
|
+
column_index(other.column_index), type(std::move(other.type)), parent(parent),
|
|
35
|
+
version(parent ? parent->version + 1 : 0) {
|
|
31
36
|
if (other.updates) {
|
|
32
37
|
updates = make_unique<UpdateSegment>(*other.updates, *this);
|
|
33
38
|
}
|
|
39
|
+
if (other.stats) {
|
|
40
|
+
stats = make_unique<SegmentStatistics>(other.stats->statistics.Copy());
|
|
41
|
+
}
|
|
34
42
|
idx_t offset = 0;
|
|
35
43
|
for (auto &segment : other.data.Segments()) {
|
|
36
44
|
this->data.AppendSegment(ColumnSegment::CreateSegment(segment, start + offset));
|
|
@@ -61,16 +69,7 @@ void ColumnData::IncrementVersion() {
|
|
|
61
69
|
}
|
|
62
70
|
|
|
63
71
|
idx_t ColumnData::GetMaxEntry() {
|
|
64
|
-
|
|
65
|
-
auto first_segment = data.GetRootSegment(l);
|
|
66
|
-
auto last_segment = data.GetLastSegment(l);
|
|
67
|
-
if (!first_segment) {
|
|
68
|
-
D_ASSERT(!last_segment);
|
|
69
|
-
return 0;
|
|
70
|
-
} else {
|
|
71
|
-
D_ASSERT(last_segment->start >= first_segment->start);
|
|
72
|
-
return last_segment->start + last_segment->count - first_segment->start;
|
|
73
|
-
}
|
|
72
|
+
return count;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
75
|
void ColumnData::InitializeScan(ColumnScanState &state) {
|
|
@@ -81,6 +80,7 @@ void ColumnData::InitializeScan(ColumnScanState &state) {
|
|
|
81
80
|
state.initialized = false;
|
|
82
81
|
state.version = version;
|
|
83
82
|
state.scan_state.reset();
|
|
83
|
+
state.last_offset = 0;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
void ColumnData::InitializeScanWithOffset(ColumnScanState &state, idx_t row_idx) {
|
|
@@ -91,6 +91,7 @@ void ColumnData::InitializeScanWithOffset(ColumnScanState &state, idx_t row_idx)
|
|
|
91
91
|
state.initialized = false;
|
|
92
92
|
state.version = version;
|
|
93
93
|
state.scan_state.reset();
|
|
94
|
+
state.last_offset = 0;
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
idx_t ColumnData::ScanVector(ColumnScanState &state, Vector &result, idx_t remaining) {
|
|
@@ -230,6 +231,46 @@ void ColumnData::Append(BaseStatistics &stats, ColumnAppendState &state, Vector
|
|
|
230
231
|
AppendData(stats, state, vdata, count);
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
void ColumnData::Append(ColumnAppendState &state, Vector &vector, idx_t count) {
|
|
235
|
+
if (parent || !stats) {
|
|
236
|
+
throw InternalException("ColumnData::Append called on a column with a parent or without stats");
|
|
237
|
+
}
|
|
238
|
+
Append(stats->statistics, state, vector, count);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
bool ColumnData::CheckZonemap(TableFilter &filter) {
|
|
242
|
+
if (!stats) {
|
|
243
|
+
throw InternalException("ColumnData::CheckZonemap called on a column without stats");
|
|
244
|
+
}
|
|
245
|
+
auto propagate_result = filter.CheckStatistics(stats->statistics);
|
|
246
|
+
if (propagate_result == FilterPropagateResult::FILTER_ALWAYS_FALSE ||
|
|
247
|
+
propagate_result == FilterPropagateResult::FILTER_FALSE_OR_NULL) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
unique_ptr<BaseStatistics> ColumnData::GetStatistics() {
|
|
254
|
+
if (!stats) {
|
|
255
|
+
throw InternalException("ColumnData::GetStatistics called on a column without stats");
|
|
256
|
+
}
|
|
257
|
+
return stats->statistics.ToUnique();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void ColumnData::MergeStatistics(const BaseStatistics &other) {
|
|
261
|
+
if (!stats) {
|
|
262
|
+
throw InternalException("ColumnData::MergeStatistics called on a column without stats");
|
|
263
|
+
}
|
|
264
|
+
return stats->statistics.Merge(other);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
void ColumnData::MergeIntoStatistics(BaseStatistics &other) {
|
|
268
|
+
if (!stats) {
|
|
269
|
+
throw InternalException("ColumnData::MergeIntoStatistics called on a column without stats");
|
|
270
|
+
}
|
|
271
|
+
return other.Merge(stats->statistics);
|
|
272
|
+
}
|
|
273
|
+
|
|
233
274
|
void ColumnData::InitializeAppend(ColumnAppendState &state) {
|
|
234
275
|
auto l = data.Lock();
|
|
235
276
|
if (data.IsEmpty(l)) {
|
|
@@ -253,6 +294,7 @@ void ColumnData::InitializeAppend(ColumnAppendState &state) {
|
|
|
253
294
|
|
|
254
295
|
void ColumnData::AppendData(BaseStatistics &stats, ColumnAppendState &state, UnifiedVectorFormat &vdata, idx_t count) {
|
|
255
296
|
idx_t offset = 0;
|
|
297
|
+
this->count += count;
|
|
256
298
|
while (true) {
|
|
257
299
|
// append the data from the vector
|
|
258
300
|
idx_t copied_elements = state.current->Append(state, vdata, offset, count);
|
|
@@ -292,6 +334,7 @@ void ColumnData::RevertAppend(row_t start_row) {
|
|
|
292
334
|
// remove any segments AFTER this segment: they should be deleted entirely
|
|
293
335
|
data.EraseSegments(l, segment_index);
|
|
294
336
|
|
|
337
|
+
this->count = start_row - this->start;
|
|
295
338
|
segment->next = nullptr;
|
|
296
339
|
transient.RevertAppend(start_row);
|
|
297
340
|
}
|
|
@@ -412,6 +455,7 @@ unique_ptr<ColumnCheckpointState> ColumnData::Checkpoint(RowGroup &row_group,
|
|
|
412
455
|
|
|
413
456
|
void ColumnData::DeserializeColumn(Deserializer &source) {
|
|
414
457
|
// load the data pointers for the column
|
|
458
|
+
this->count = 0;
|
|
415
459
|
idx_t data_pointer_count = source.Read<idx_t>();
|
|
416
460
|
for (idx_t data_ptr = 0; data_ptr < data_pointer_count; data_ptr++) {
|
|
417
461
|
// read the data pointer
|
|
@@ -420,15 +464,20 @@ void ColumnData::DeserializeColumn(Deserializer &source) {
|
|
|
420
464
|
auto block_pointer_block_id = source.Read<block_id_t>();
|
|
421
465
|
auto block_pointer_offset = source.Read<uint32_t>();
|
|
422
466
|
auto compression_type = source.Read<CompressionType>();
|
|
423
|
-
auto
|
|
467
|
+
auto segment_stats = BaseStatistics::Deserialize(source, type);
|
|
468
|
+
if (stats) {
|
|
469
|
+
stats->statistics.Merge(segment_stats);
|
|
470
|
+
}
|
|
424
471
|
|
|
425
|
-
DataPointer data_pointer(std::move(
|
|
472
|
+
DataPointer data_pointer(std::move(segment_stats));
|
|
426
473
|
data_pointer.row_start = row_start;
|
|
427
474
|
data_pointer.tuple_count = tuple_count;
|
|
428
475
|
data_pointer.block_pointer.block_id = block_pointer_block_id;
|
|
429
476
|
data_pointer.block_pointer.offset = block_pointer_offset;
|
|
430
477
|
data_pointer.compression_type = compression_type;
|
|
431
478
|
|
|
479
|
+
this->count += tuple_count;
|
|
480
|
+
|
|
432
481
|
// create a persistent segment
|
|
433
482
|
auto segment = ColumnSegment::CreatePersistentSegment(
|
|
434
483
|
GetDatabase(), block_manager, data_pointer.block_pointer.block_id, data_pointer.block_pointer.offset, type,
|
|
@@ -495,14 +544,22 @@ void ColumnData::Verify(RowGroup &parent) {
|
|
|
495
544
|
#ifdef DEBUG
|
|
496
545
|
D_ASSERT(this->start == parent.start);
|
|
497
546
|
data.Verify();
|
|
547
|
+
if (type.InternalType() == PhysicalType::STRUCT) {
|
|
548
|
+
// structs don't have segments
|
|
549
|
+
D_ASSERT(!data.GetRootSegment());
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
498
552
|
idx_t current_index = 0;
|
|
499
553
|
idx_t current_start = this->start;
|
|
554
|
+
idx_t total_count = 0;
|
|
500
555
|
for (auto &segment : data.Segments()) {
|
|
501
556
|
D_ASSERT(segment.index == current_index);
|
|
502
557
|
D_ASSERT(segment.start == current_start);
|
|
503
558
|
current_start += segment.count;
|
|
559
|
+
total_count += segment.count;
|
|
504
560
|
current_index++;
|
|
505
561
|
}
|
|
562
|
+
D_ASSERT(this->count == total_count);
|
|
506
563
|
#endif
|
|
507
564
|
}
|
|
508
565
|
|