duckdb 0.7.2-dev16.0 → 0.7.2-dev314.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/binding.gyp +2 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +2 -0
- package/src/duckdb/extension/icu/icu-table-range.cpp +194 -0
- package/src/duckdb/extension/icu/include/icu-table-range.hpp +17 -0
- package/src/duckdb/extension/parquet/column_reader.cpp +5 -6
- package/src/duckdb/extension/parquet/column_writer.cpp +0 -1
- package/src/duckdb/extension/parquet/include/column_reader.hpp +1 -2
- package/src/duckdb/extension/parquet/include/generated_column_reader.hpp +1 -11
- package/src/duckdb/extension/parquet/parquet-extension.cpp +11 -2
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +26 -32
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +4 -0
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +7 -6
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +20 -1
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/sort/sort_state.cpp +5 -7
- package/src/duckdb/src/common/types/bit.cpp +95 -58
- package/src/duckdb/src/common/types/value.cpp +149 -53
- package/src/duckdb/src/common/types/vector.cpp +13 -10
- package/src/duckdb/src/execution/column_binding_resolver.cpp +6 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +4 -5
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +2 -3
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +32 -6
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +15 -15
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +18 -12
- package/src/duckdb/src/function/aggregate/algebraic/avg.cpp +0 -6
- package/src/duckdb/src/function/aggregate/distributive/bitagg.cpp +99 -95
- package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +254 -0
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +2 -4
- package/src/duckdb/src/function/aggregate/distributive/sum.cpp +11 -16
- package/src/duckdb/src/function/aggregate/distributive_functions.cpp +1 -0
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +16 -5
- package/src/duckdb/src/function/cast/bit_cast.cpp +0 -2
- package/src/duckdb/src/function/cast/blob_cast.cpp +0 -1
- package/src/duckdb/src/function/scalar/bit/bitstring.cpp +99 -0
- package/src/duckdb/src/function/scalar/date/date_diff.cpp +0 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +17 -25
- package/src/duckdb/src/function/scalar/date/date_sub.cpp +0 -1
- package/src/duckdb/src/function/scalar/date/date_trunc.cpp +10 -14
- package/src/duckdb/src/function/scalar/generic/stats.cpp +2 -4
- package/src/duckdb/src/function/scalar/list/flatten.cpp +5 -12
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +3 -8
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +5 -12
- package/src/duckdb/src/function/scalar/list/list_value.cpp +5 -9
- package/src/duckdb/src/function/scalar/map/map_entries.cpp +61 -0
- package/src/duckdb/src/function/scalar/map/map_keys_values.cpp +97 -0
- package/src/duckdb/src/function/scalar/math/numeric.cpp +14 -17
- package/src/duckdb/src/function/scalar/nested_functions.cpp +3 -0
- package/src/duckdb/src/function/scalar/operators/add.cpp +0 -9
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +29 -48
- package/src/duckdb/src/function/scalar/operators/bitwise.cpp +0 -63
- package/src/duckdb/src/function/scalar/operators/multiply.cpp +0 -6
- package/src/duckdb/src/function/scalar/operators/subtract.cpp +0 -6
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/instr.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/length.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/like.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/substring.cpp +2 -6
- package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +4 -9
- package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +10 -13
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +5 -6
- package/src/duckdb/src/function/table/read_csv.cpp +9 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/table_function.cpp +19 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +6 -8
- package/src/duckdb/src/include/duckdb/common/constants.hpp +0 -19
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/tableref_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/types/bit.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -8
- package/src/duckdb/src/include/duckdb/common/types.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +5 -0
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +12 -3
- package/src/duckdb/src/include/duckdb/function/scalar/bit_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +12 -0
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/{alter_function_info.hpp → alter_scalar_function_info.hpp} +13 -13
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_function_info.hpp +47 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/statement/multi_statement.hpp +28 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +76 -0
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +28 -0
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +8 -0
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +76 -44
- package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_fetch.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_fetch.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +93 -29
- package/src/duckdb/src/include/duckdb/storage/statistics/column_statistics.hpp +22 -3
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +6 -6
- package/src/duckdb/src/include/duckdb/storage/statistics/list_stats.hpp +41 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/node_statistics.hpp +26 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +157 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/segment_statistics.hpp +2 -7
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +74 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_stats.hpp +42 -0
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +2 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +4 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +5 -0
- package/src/duckdb/src/include/duckdb.h +49 -1
- package/src/duckdb/src/include/duckdb.hpp +0 -1
- package/src/duckdb/src/main/capi/pending-c.cpp +16 -3
- package/src/duckdb/src/main/capi/result-c.cpp +27 -1
- package/src/duckdb/src/main/capi/stream-c.cpp +25 -0
- package/src/duckdb/src/main/client_context.cpp +8 -1
- package/src/duckdb/src/main/config.cpp +66 -1
- package/src/duckdb/src/main/database.cpp +10 -2
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +98 -67
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +16 -3
- package/src/duckdb/src/optimizer/statistics/expression/propagate_aggregate.cpp +9 -3
- package/src/duckdb/src/optimizer/statistics/expression/propagate_and_compress.cpp +6 -7
- package/src/duckdb/src/optimizer/statistics/expression/propagate_cast.cpp +14 -11
- package/src/duckdb/src/optimizer/statistics/expression/propagate_columnref.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_comparison.cpp +13 -15
- package/src/duckdb/src/optimizer/statistics/expression/propagate_conjunction.cpp +0 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_constant.cpp +3 -75
- package/src/duckdb/src/optimizer/statistics/expression/propagate_function.cpp +7 -2
- package/src/duckdb/src/optimizer/statistics/expression/propagate_operator.cpp +10 -0
- package/src/duckdb/src/optimizer/statistics/operator/propagate_aggregate.cpp +2 -3
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +28 -31
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +4 -5
- package/src/duckdb/src/optimizer/statistics/operator/propagate_set_operation.cpp +3 -3
- package/src/duckdb/src/optimizer/statistics_propagator.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +7 -3
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +56 -0
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +51 -0
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -2
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +6 -0
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +8 -0
- package/src/duckdb/src/parser/query_node.cpp +1 -1
- package/src/duckdb/src/parser/statement/multi_statement.cpp +18 -0
- package/src/duckdb/src/parser/tableref/pivotref.cpp +296 -0
- package/src/duckdb/src/parser/tableref.cpp +3 -0
- package/src/duckdb/src/parser/transform/helpers/transform_alias.cpp +12 -6
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +24 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +4 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +4 -0
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +150 -0
- package/src/duckdb/src/parser/transform/statement/transform_select.cpp +8 -0
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +4 -0
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +105 -0
- package/src/duckdb/src/parser/transform/tableref/transform_tableref.cpp +2 -0
- package/src/duckdb/src/parser/transformer.cpp +15 -3
- package/src/duckdb/src/planner/bind_context.cpp +16 -0
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +11 -3
- package/src/duckdb/src/planner/binder/query_node/plan_select_node.cpp +0 -1
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_logical_plan.cpp +17 -0
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +9 -0
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +365 -0
- package/src/duckdb/src/planner/binder.cpp +7 -1
- package/src/duckdb/src/planner/bound_result_modifier.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +1 -1
- package/src/duckdb/src/planner/filter/constant_filter.cpp +4 -6
- package/src/duckdb/src/planner/pragma_handler.cpp +10 -2
- package/src/duckdb/src/storage/buffer_manager.cpp +44 -46
- package/src/duckdb/src/storage/checkpoint/row_group_writer.cpp +1 -1
- package/src/duckdb/src/storage/checkpoint/table_data_reader.cpp +1 -4
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +4 -4
- package/src/duckdb/src/storage/compression/bitpacking.cpp +28 -24
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +43 -45
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +9 -10
- package/src/duckdb/src/storage/compression/patas.cpp +1 -1
- package/src/duckdb/src/storage/compression/rle.cpp +19 -15
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +5 -5
- package/src/duckdb/src/storage/data_table.cpp +4 -6
- package/src/duckdb/src/storage/statistics/base_statistics.cpp +373 -128
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +58 -3
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +4 -9
- package/src/duckdb/src/storage/statistics/list_stats.cpp +117 -0
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +529 -0
- package/src/duckdb/src/storage/statistics/segment_statistics.cpp +2 -11
- package/src/duckdb/src/storage/statistics/string_stats.cpp +273 -0
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +131 -0
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +3 -4
- package/src/duckdb/src/storage/table/column_data.cpp +16 -11
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +2 -3
- package/src/duckdb/src/storage/table/column_segment.cpp +6 -8
- package/src/duckdb/src/storage/table/list_column_data.cpp +39 -58
- package/src/duckdb/src/storage/table/row_group.cpp +24 -23
- package/src/duckdb/src/storage/table/row_group_collection.cpp +12 -12
- package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -6
- package/src/duckdb/src/storage/table/struct_column_data.cpp +15 -16
- package/src/duckdb/src/storage/table/table_statistics.cpp +27 -7
- package/src/duckdb/src/storage/table/update_segment.cpp +10 -12
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +3 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +34 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +1020 -530
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +7 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +23560 -22737
- package/src/duckdb/ub_src_function_aggregate_distributive.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_bit.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_map.cpp +4 -0
- package/src/duckdb/ub_src_main_capi.cpp +2 -0
- package/src/duckdb/ub_src_parser_parsed_data.cpp +4 -2
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_tableref.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_tableref.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_tableref.cpp +2 -0
- package/src/duckdb/ub_src_storage_statistics.cpp +4 -6
- package/src/duckdb/src/include/duckdb/main/loadable_extension.hpp +0 -59
- package/src/duckdb/src/include/duckdb/storage/statistics/list_statistics.hpp +0 -36
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_statistics.hpp +0 -75
- package/src/duckdb/src/include/duckdb/storage/statistics/string_statistics.hpp +0 -49
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_statistics.hpp +0 -36
- package/src/duckdb/src/include/duckdb/storage/statistics/validity_statistics.hpp +0 -45
- package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +0 -55
- package/src/duckdb/src/storage/statistics/list_statistics.cpp +0 -94
- package/src/duckdb/src/storage/statistics/numeric_statistics.cpp +0 -307
- package/src/duckdb/src/storage/statistics/string_statistics.cpp +0 -220
- package/src/duckdb/src/storage/statistics/struct_statistics.cpp +0 -108
- package/src/duckdb/src/storage/statistics/validity_statistics.cpp +0 -91
@@ -6,10 +6,7 @@ namespace duckdb {
|
|
6
6
|
void TableStatistics::Initialize(const vector<LogicalType> &types, PersistentTableData &data) {
|
7
7
|
D_ASSERT(Empty());
|
8
8
|
|
9
|
-
column_stats
|
10
|
-
for (auto &stats : data.column_stats) {
|
11
|
-
column_stats.push_back(make_shared<ColumnStatistics>(std::move(stats)));
|
12
|
-
}
|
9
|
+
column_stats = std::move(data.table_stats.column_stats);
|
13
10
|
if (column_stats.size() != types.size()) { // LCOV_EXCL_START
|
14
11
|
throw IOException("Table statistics column count is not aligned with table column count. Corrupt file?");
|
15
12
|
} // LCOV_EXCL_STOP
|
@@ -70,7 +67,7 @@ void TableStatistics::MergeStats(TableStatistics &other) {
|
|
70
67
|
auto l = GetLock();
|
71
68
|
D_ASSERT(column_stats.size() == other.column_stats.size());
|
72
69
|
for (idx_t i = 0; i < column_stats.size(); i++) {
|
73
|
-
column_stats[i]->
|
70
|
+
column_stats[i]->Merge(*other.column_stats[i]);
|
74
71
|
}
|
75
72
|
}
|
76
73
|
|
@@ -80,7 +77,7 @@ void TableStatistics::MergeStats(idx_t i, BaseStatistics &stats) {
|
|
80
77
|
}
|
81
78
|
|
82
79
|
void TableStatistics::MergeStats(TableStatisticsLock &lock, idx_t i, BaseStatistics &stats) {
|
83
|
-
column_stats[i]->
|
80
|
+
column_stats[i]->Statistics().Merge(stats);
|
84
81
|
}
|
85
82
|
|
86
83
|
ColumnStatistics &TableStatistics::GetStats(idx_t i) {
|
@@ -89,7 +86,30 @@ ColumnStatistics &TableStatistics::GetStats(idx_t i) {
|
|
89
86
|
|
90
87
|
unique_ptr<BaseStatistics> TableStatistics::CopyStats(idx_t i) {
|
91
88
|
lock_guard<mutex> l(stats_lock);
|
92
|
-
|
89
|
+
auto result = column_stats[i]->Statistics().Copy();
|
90
|
+
if (column_stats[i]->HasDistinctStats()) {
|
91
|
+
result.SetDistinctCount(column_stats[i]->DistinctStats().GetCount());
|
92
|
+
}
|
93
|
+
return result.ToUnique();
|
94
|
+
}
|
95
|
+
|
96
|
+
void TableStatistics::CopyStats(TableStatistics &other) {
|
97
|
+
for (auto &stats : column_stats) {
|
98
|
+
other.column_stats.push_back(stats->Copy());
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
void TableStatistics::Serialize(Serializer &serializer) {
|
103
|
+
for (auto &stats : column_stats) {
|
104
|
+
stats->Serialize(serializer);
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
void TableStatistics::Deserialize(Deserializer &source, ColumnList &columns) {
|
109
|
+
for (auto &col : columns.Physical()) {
|
110
|
+
auto stats = ColumnStatistics::Deserialize(source, col.GetType());
|
111
|
+
column_stats.push_back(std::move(stats));
|
112
|
+
}
|
93
113
|
}
|
94
114
|
|
95
115
|
unique_ptr<TableStatisticsLock> TableStatistics::GetLock() {
|
@@ -1,9 +1,7 @@
|
|
1
1
|
#include "duckdb/storage/table/update_segment.hpp"
|
2
2
|
|
3
3
|
#include "duckdb/storage/statistics/distinct_statistics.hpp"
|
4
|
-
|
5
|
-
#include "duckdb/storage/statistics/string_statistics.hpp"
|
6
|
-
#include "duckdb/storage/statistics/validity_statistics.hpp"
|
4
|
+
|
7
5
|
#include "duckdb/storage/table/column_data.hpp"
|
8
6
|
#include "duckdb/transaction/duck_transaction.hpp"
|
9
7
|
#include "duckdb/transaction/update_info.hpp"
|
@@ -55,7 +53,7 @@ UpdateSegment::~UpdateSegment() {
|
|
55
53
|
}
|
56
54
|
|
57
55
|
void UpdateSegment::ClearUpdates() {
|
58
|
-
stats.
|
56
|
+
stats.statistics.Copy(BaseStatistics::CreateEmpty(stats.statistics.GetType()));
|
59
57
|
root.reset();
|
60
58
|
heap.Destroy();
|
61
59
|
}
|
@@ -905,17 +903,17 @@ static UpdateSegment::merge_update_function_t GetMergeUpdateFunction(PhysicalTyp
|
|
905
903
|
//===--------------------------------------------------------------------===//
|
906
904
|
unique_ptr<BaseStatistics> UpdateSegment::GetStatistics() {
|
907
905
|
lock_guard<mutex> stats_guard(stats_lock);
|
908
|
-
return stats.statistics
|
906
|
+
return stats.statistics.ToUnique();
|
909
907
|
}
|
910
908
|
|
911
909
|
idx_t UpdateValidityStatistics(UpdateSegment *segment, SegmentStatistics &stats, Vector &update, idx_t count,
|
912
910
|
SelectionVector &sel) {
|
913
911
|
auto &mask = FlatVector::Validity(update);
|
914
|
-
auto &validity =
|
915
|
-
if (!mask.AllValid() && !validity.
|
912
|
+
auto &validity = stats.statistics;
|
913
|
+
if (!mask.AllValid() && !validity.CanHaveNull()) {
|
916
914
|
for (idx_t i = 0; i < count; i++) {
|
917
915
|
if (!mask.RowIsValid(i)) {
|
918
|
-
validity.
|
916
|
+
validity.SetHasNull();
|
919
917
|
break;
|
920
918
|
}
|
921
919
|
}
|
@@ -932,7 +930,7 @@ idx_t TemplatedUpdateNumericStatistics(UpdateSegment *segment, SegmentStatistics
|
|
932
930
|
|
933
931
|
if (mask.AllValid()) {
|
934
932
|
for (idx_t i = 0; i < count; i++) {
|
935
|
-
|
933
|
+
NumericStats::Update<T>(stats.statistics, update_data[i]);
|
936
934
|
}
|
937
935
|
sel.Initialize(nullptr);
|
938
936
|
return count;
|
@@ -942,7 +940,7 @@ idx_t TemplatedUpdateNumericStatistics(UpdateSegment *segment, SegmentStatistics
|
|
942
940
|
for (idx_t i = 0; i < count; i++) {
|
943
941
|
if (mask.RowIsValid(i)) {
|
944
942
|
sel.set_index(not_null_count++, i);
|
945
|
-
|
943
|
+
NumericStats::Update<T>(stats.statistics, update_data[i]);
|
946
944
|
}
|
947
945
|
}
|
948
946
|
return not_null_count;
|
@@ -955,7 +953,7 @@ idx_t UpdateStringStatistics(UpdateSegment *segment, SegmentStatistics &stats, V
|
|
955
953
|
auto &mask = FlatVector::Validity(update);
|
956
954
|
if (mask.AllValid()) {
|
957
955
|
for (idx_t i = 0; i < count; i++) {
|
958
|
-
(
|
956
|
+
StringStats::Update(stats.statistics, update_data[i]);
|
959
957
|
if (!update_data[i].IsInlined()) {
|
960
958
|
update_data[i] = segment->GetStringHeap().AddBlob(update_data[i]);
|
961
959
|
}
|
@@ -968,7 +966,7 @@ idx_t UpdateStringStatistics(UpdateSegment *segment, SegmentStatistics &stats, V
|
|
968
966
|
for (idx_t i = 0; i < count; i++) {
|
969
967
|
if (mask.RowIsValid(i)) {
|
970
968
|
sel.set_index(not_null_count++, i);
|
971
|
-
(
|
969
|
+
StringStats::Update(stats.statistics, update_data[i]);
|
972
970
|
if (!update_data[i].IsInlined()) {
|
973
971
|
update_data[i] = segment->GetStringHeap().AddBlob(update_data[i]);
|
974
972
|
}
|
@@ -1162,6 +1162,37 @@ typedef struct PGUpdateStmt {
|
|
1162
1162
|
PGWithClause *withClause; /* WITH clause */
|
1163
1163
|
} PGUpdateStmt;
|
1164
1164
|
|
1165
|
+
/* ----------------------
|
1166
|
+
* Pivot Expression
|
1167
|
+
* ----------------------
|
1168
|
+
*/
|
1169
|
+
typedef struct PGPivot {
|
1170
|
+
PGNodeTag type;
|
1171
|
+
PGList *pivot_columns; /* The column names to pivot on */
|
1172
|
+
PGList *pivot_value; /* The set of pivot values */
|
1173
|
+
char *pivot_enum; /* The enum to fetch the unique values from */
|
1174
|
+
} PGPivot;
|
1175
|
+
|
1176
|
+
typedef struct PGPivotExpr {
|
1177
|
+
PGNodeTag type;
|
1178
|
+
PGNode *source; /* the source subtree */
|
1179
|
+
PGList *aggrs; /* The aggregations to pivot over (PIVOT only) */
|
1180
|
+
PGList *unpivots; /* The names to unpivot over (UNPIVOT only) */
|
1181
|
+
PGList *pivots; /* The set of pivot values */
|
1182
|
+
PGList *groups; /* The set of groups to pivot over (if any) */
|
1183
|
+
PGAlias *alias; /* table alias & optional column aliases */
|
1184
|
+
bool include_nulls; /* Whether or not to include NULL values (UNPIVOT only */
|
1185
|
+
} PGPivotExpr;
|
1186
|
+
|
1187
|
+
typedef struct PGPivotStmt {
|
1188
|
+
PGNodeTag type;
|
1189
|
+
PGNode *source; /* The source to pivot */
|
1190
|
+
PGList *aggrs; /* The aggregations to pivot over (PIVOT only) */
|
1191
|
+
PGList *unpivots; /* The names to unpivot over (UNPIVOT only) */
|
1192
|
+
PGList *columns; /* The set of columns to pivot over */
|
1193
|
+
PGList *groups; /* The set of groups to pivot over (if any) */
|
1194
|
+
} PGPivotStmt;
|
1195
|
+
|
1165
1196
|
/* ----------------------
|
1166
1197
|
* Select Statement
|
1167
1198
|
*
|
@@ -1204,6 +1235,9 @@ typedef struct PGSelectStmt {
|
|
1204
1235
|
*/
|
1205
1236
|
PGList *valuesLists; /* untransformed list of expression lists */
|
1206
1237
|
|
1238
|
+
/* When representing a pivot statement, all values are NULL besides the pivot field */
|
1239
|
+
PGPivotStmt *pivot; /* PIVOT statement */
|
1240
|
+
|
1207
1241
|
/*
|
1208
1242
|
* These fields are used in both "leaf" SelectStmts and upper-level
|
1209
1243
|
* SelectStmts.
|
@@ -2107,5 +2141,4 @@ typedef struct PGUseStmt {
|
|
2107
2141
|
} PGUseStmt;
|
2108
2142
|
|
2109
2143
|
|
2110
|
-
|
2111
2144
|
}
|