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
@@ -4,66 +4,35 @@
|
|
4
4
|
|
5
5
|
namespace duckdb {
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
memset(res_buf, 0, input.GetSize());
|
11
|
-
res_buf[0] = buf[0];
|
7
|
+
// **** helper functions ****
|
8
|
+
static char ComputePadding(idx_t len) {
|
9
|
+
return (8 - (len % 8)) % 8;
|
12
10
|
}
|
13
11
|
|
14
|
-
idx_t Bit::
|
15
|
-
|
12
|
+
idx_t Bit::ComputeBitstringLen(idx_t len) {
|
13
|
+
len = len % 8 ? (len / 8) + 1 : len / 8;
|
14
|
+
return ++len; // additional first byte to store info on zero padding
|
16
15
|
}
|
17
16
|
|
18
|
-
idx_t Bit::
|
19
|
-
|
17
|
+
inline idx_t Bit::GetPadding(const string_t &bit_string) {
|
18
|
+
auto data = (const_data_ptr_t)bit_string.GetDataUnsafe();
|
19
|
+
return data[0];
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
const char *buf =
|
25
|
-
|
26
|
-
|
27
|
-
count += (buf[byte_idx] & (1 << bit_idx)) ? 1 : 0;
|
28
|
-
}
|
29
|
-
}
|
30
|
-
return count;
|
22
|
+
void Bit::SetEmptyBitString(string_t &target, string_t &input) {
|
23
|
+
char *res_buf = target.GetDataWriteable();
|
24
|
+
const char *buf = input.GetDataUnsafe();
|
25
|
+
memset(res_buf, 0, input.GetSize());
|
26
|
+
res_buf[0] = buf[0];
|
31
27
|
}
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
idx_t substr_idx = 0;
|
38
|
-
|
39
|
-
for (idx_t bit_idx = GetPadding(bits); bit_idx < 8; bit_idx++) {
|
40
|
-
idx_t bit = buf[1] & (1 << (7 - bit_idx)) ? 1 : 0;
|
41
|
-
if (bit == GetBit(substring, substr_idx)) {
|
42
|
-
substr_idx++;
|
43
|
-
if (substr_idx == substr_len) {
|
44
|
-
return (bit_idx - GetPadding(bits)) - substr_len + 2;
|
45
|
-
}
|
46
|
-
} else {
|
47
|
-
substr_idx = 0;
|
48
|
-
}
|
49
|
-
}
|
50
|
-
|
51
|
-
for (idx_t byte_idx = 2; byte_idx < len; byte_idx++) {
|
52
|
-
for (idx_t bit_idx = 0; bit_idx < 8; bit_idx++) {
|
53
|
-
idx_t bit = buf[byte_idx] & (1 << (7 - bit_idx)) ? 1 : 0;
|
54
|
-
if (bit == GetBit(substring, substr_idx)) {
|
55
|
-
substr_idx++;
|
56
|
-
if (substr_idx == substr_len) {
|
57
|
-
return (((byte_idx - 1) * 8) + bit_idx - GetPadding(bits)) - substr_len + 2;
|
58
|
-
}
|
59
|
-
} else {
|
60
|
-
substr_idx = 0;
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
return 0;
|
29
|
+
void Bit::SetEmptyBitString(string_t &target, idx_t len) {
|
30
|
+
char *res_buf = target.GetDataWriteable();
|
31
|
+
memset(res_buf, 0, target.GetSize());
|
32
|
+
res_buf[0] = ComputePadding(len);
|
65
33
|
}
|
66
34
|
|
35
|
+
// **** casting functions ****
|
67
36
|
void Bit::ToString(string_t bits, char *output) {
|
68
37
|
auto data = (const_data_ptr_t)bits.GetDataUnsafe();
|
69
38
|
auto len = bits.GetSize();
|
@@ -101,8 +70,12 @@ bool Bit::TryGetBitStringSize(string_t str, idx_t &str_len, string *error_messag
|
|
101
70
|
return false;
|
102
71
|
}
|
103
72
|
}
|
104
|
-
|
105
|
-
|
73
|
+
if (str_len == 0) {
|
74
|
+
string error = "Cannot cast empty string to BIT";
|
75
|
+
HandleCastError::AssignError(error, error_message);
|
76
|
+
return false;
|
77
|
+
}
|
78
|
+
str_len = ComputeBitstringLen(str_len);
|
106
79
|
return true;
|
107
80
|
}
|
108
81
|
|
@@ -151,6 +124,75 @@ string Bit::ToBit(string_t str) {
|
|
151
124
|
return string(buffer.get(), bit_len);
|
152
125
|
}
|
153
126
|
|
127
|
+
// **** scalar functions ****
|
128
|
+
void Bit::BitString(const string_t &input, const idx_t &len, string_t &result) {
|
129
|
+
char *res_buf = result.GetDataWriteable();
|
130
|
+
const char *buf = input.GetDataUnsafe();
|
131
|
+
|
132
|
+
res_buf[0] = ComputePadding(len);
|
133
|
+
for (idx_t i = 0; i < Bit::BitLength(result); i++) {
|
134
|
+
if (i < len - input.GetSize()) {
|
135
|
+
Bit::SetBit(result, i, 0);
|
136
|
+
} else {
|
137
|
+
idx_t bit = buf[i - (len - input.GetSize())] == '1' ? 1 : 0;
|
138
|
+
Bit::SetBit(result, i, bit);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
idx_t Bit::BitLength(string_t bits) {
|
144
|
+
return ((bits.GetSize() - 1) * 8) - GetPadding(bits);
|
145
|
+
}
|
146
|
+
|
147
|
+
idx_t Bit::OctetLength(string_t bits) {
|
148
|
+
return bits.GetSize() - 1;
|
149
|
+
}
|
150
|
+
|
151
|
+
idx_t Bit::BitCount(string_t bits) {
|
152
|
+
idx_t count = 0;
|
153
|
+
const char *buf = bits.GetDataUnsafe();
|
154
|
+
for (idx_t byte_idx = 1; byte_idx < OctetLength(bits) + 1; byte_idx++) {
|
155
|
+
for (idx_t bit_idx = 0; bit_idx < 8; bit_idx++) {
|
156
|
+
count += (buf[byte_idx] & (1 << bit_idx)) ? 1 : 0;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
return count;
|
160
|
+
}
|
161
|
+
|
162
|
+
idx_t Bit::BitPosition(string_t substring, string_t bits) {
|
163
|
+
const char *buf = bits.GetDataUnsafe();
|
164
|
+
auto len = bits.GetSize();
|
165
|
+
auto substr_len = BitLength(substring);
|
166
|
+
idx_t substr_idx = 0;
|
167
|
+
|
168
|
+
for (idx_t bit_idx = GetPadding(bits); bit_idx < 8; bit_idx++) {
|
169
|
+
idx_t bit = buf[1] & (1 << (7 - bit_idx)) ? 1 : 0;
|
170
|
+
if (bit == GetBit(substring, substr_idx)) {
|
171
|
+
substr_idx++;
|
172
|
+
if (substr_idx == substr_len) {
|
173
|
+
return (bit_idx - GetPadding(bits)) - substr_len + 2;
|
174
|
+
}
|
175
|
+
} else {
|
176
|
+
substr_idx = 0;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
for (idx_t byte_idx = 2; byte_idx < len; byte_idx++) {
|
181
|
+
for (idx_t bit_idx = 0; bit_idx < 8; bit_idx++) {
|
182
|
+
idx_t bit = buf[byte_idx] & (1 << (7 - bit_idx)) ? 1 : 0;
|
183
|
+
if (bit == GetBit(substring, substr_idx)) {
|
184
|
+
substr_idx++;
|
185
|
+
if (substr_idx == substr_len) {
|
186
|
+
return (((byte_idx - 1) * 8) + bit_idx - GetPadding(bits)) - substr_len + 2;
|
187
|
+
}
|
188
|
+
} else {
|
189
|
+
substr_idx = 0;
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
return 0;
|
194
|
+
}
|
195
|
+
|
154
196
|
idx_t Bit::GetBit(string_t bit_string, idx_t n) {
|
155
197
|
const char *buf = bit_string.GetDataUnsafe();
|
156
198
|
n += GetPadding(bit_string);
|
@@ -187,12 +229,7 @@ void Bit::SetBit(string_t &bit_string, idx_t n, idx_t new_value) {
|
|
187
229
|
}
|
188
230
|
}
|
189
231
|
|
190
|
-
|
191
|
-
auto data = (const_data_ptr_t)bit_string.GetDataUnsafe();
|
192
|
-
return data[0];
|
193
|
-
}
|
194
|
-
|
195
|
-
// **** BITWISE OPERATORS ****
|
232
|
+
// **** BITWISE operators ****
|
196
233
|
void Bit::RightShift(const string_t &bit_string, const idx_t &shift, string_t &result) {
|
197
234
|
char *res_buf = result.GetDataWriteable();
|
198
235
|
const char *buf = bit_string.GetDataUnsafe();
|
@@ -35,6 +35,94 @@
|
|
35
35
|
|
36
36
|
namespace duckdb {
|
37
37
|
|
38
|
+
//===--------------------------------------------------------------------===//
|
39
|
+
// Extra Value Info
|
40
|
+
//===--------------------------------------------------------------------===//
|
41
|
+
enum class ExtraValueInfoType : uint8_t { INVALID_TYPE_INFO = 0, STRING_VALUE_INFO = 1, NESTED_VALUE_INFO = 2 };
|
42
|
+
|
43
|
+
struct ExtraValueInfo {
|
44
|
+
explicit ExtraValueInfo(ExtraValueInfoType type) : type(type) {
|
45
|
+
}
|
46
|
+
virtual ~ExtraValueInfo() {
|
47
|
+
}
|
48
|
+
|
49
|
+
ExtraValueInfoType type;
|
50
|
+
|
51
|
+
public:
|
52
|
+
bool Equals(ExtraValueInfo *other_p) const {
|
53
|
+
if (!other_p) {
|
54
|
+
return false;
|
55
|
+
}
|
56
|
+
if (type != other_p->type) {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
return EqualsInternal(other_p);
|
60
|
+
}
|
61
|
+
|
62
|
+
template <class T>
|
63
|
+
T &Get() {
|
64
|
+
if (type != T::TYPE) {
|
65
|
+
throw InternalException("ExtraValueInfo type mismatch");
|
66
|
+
}
|
67
|
+
return (T &)*this;
|
68
|
+
}
|
69
|
+
|
70
|
+
protected:
|
71
|
+
virtual bool EqualsInternal(ExtraValueInfo *other_p) const {
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
};
|
75
|
+
|
76
|
+
//===--------------------------------------------------------------------===//
|
77
|
+
// String Value Info
|
78
|
+
//===--------------------------------------------------------------------===//
|
79
|
+
struct StringValueInfo : public ExtraValueInfo {
|
80
|
+
static constexpr const ExtraValueInfoType TYPE = ExtraValueInfoType::STRING_VALUE_INFO;
|
81
|
+
|
82
|
+
public:
|
83
|
+
explicit StringValueInfo(string str_p)
|
84
|
+
: ExtraValueInfo(ExtraValueInfoType::STRING_VALUE_INFO), str(std::move(str_p)) {
|
85
|
+
}
|
86
|
+
|
87
|
+
const string &GetString() {
|
88
|
+
return str;
|
89
|
+
}
|
90
|
+
|
91
|
+
protected:
|
92
|
+
bool EqualsInternal(ExtraValueInfo *other_p) const override {
|
93
|
+
return other_p->Get<StringValueInfo>().str == str;
|
94
|
+
}
|
95
|
+
|
96
|
+
string str;
|
97
|
+
};
|
98
|
+
|
99
|
+
//===--------------------------------------------------------------------===//
|
100
|
+
// Nested Value Info
|
101
|
+
//===--------------------------------------------------------------------===//
|
102
|
+
struct NestedValueInfo : public ExtraValueInfo {
|
103
|
+
static constexpr const ExtraValueInfoType TYPE = ExtraValueInfoType::NESTED_VALUE_INFO;
|
104
|
+
|
105
|
+
public:
|
106
|
+
NestedValueInfo() : ExtraValueInfo(ExtraValueInfoType::NESTED_VALUE_INFO) {
|
107
|
+
}
|
108
|
+
explicit NestedValueInfo(vector<Value> values_p)
|
109
|
+
: ExtraValueInfo(ExtraValueInfoType::NESTED_VALUE_INFO), values(std::move(values_p)) {
|
110
|
+
}
|
111
|
+
|
112
|
+
const vector<Value> &GetValues() {
|
113
|
+
return values;
|
114
|
+
}
|
115
|
+
|
116
|
+
protected:
|
117
|
+
bool EqualsInternal(ExtraValueInfo *other_p) const override {
|
118
|
+
return other_p->Get<NestedValueInfo>().values == values;
|
119
|
+
}
|
120
|
+
|
121
|
+
vector<Value> values;
|
122
|
+
};
|
123
|
+
//===--------------------------------------------------------------------===//
|
124
|
+
// Value
|
125
|
+
//===--------------------------------------------------------------------===//
|
38
126
|
Value::Value(LogicalType type) : type_(std::move(type)), is_null(true) {
|
39
127
|
}
|
40
128
|
|
@@ -60,36 +148,36 @@ Value::Value(const char *val) : Value(val ? string(val) : string()) {
|
|
60
148
|
Value::Value(std::nullptr_t val) : Value(LogicalType::VARCHAR) {
|
61
149
|
}
|
62
150
|
|
63
|
-
Value::Value(string_t val) : Value(
|
151
|
+
Value::Value(string_t val) : Value(val.GetString()) {
|
64
152
|
}
|
65
153
|
|
66
|
-
Value::Value(string val) : type_(LogicalType::VARCHAR), is_null(false)
|
67
|
-
if (!Value::StringIsValid(
|
68
|
-
throw Exception(ErrorManager::InvalidUnicodeError(
|
154
|
+
Value::Value(string val) : type_(LogicalType::VARCHAR), is_null(false) {
|
155
|
+
if (!Value::StringIsValid(val.c_str(), val.size())) {
|
156
|
+
throw Exception(ErrorManager::InvalidUnicodeError(val, "value construction"));
|
69
157
|
}
|
158
|
+
value_info_ = make_shared<StringValueInfo>(std::move(val));
|
70
159
|
}
|
71
160
|
|
72
161
|
Value::~Value() {
|
73
162
|
}
|
74
163
|
|
75
164
|
Value::Value(const Value &other)
|
76
|
-
: type_(other.type_), is_null(other.is_null), value_(other.value_),
|
77
|
-
struct_value(other.struct_value), list_value(other.list_value) {
|
165
|
+
: type_(other.type_), is_null(other.is_null), value_(other.value_), value_info_(other.value_info_) {
|
78
166
|
}
|
79
167
|
|
80
168
|
Value::Value(Value &&other) noexcept
|
81
169
|
: type_(std::move(other.type_)), is_null(other.is_null), value_(other.value_),
|
82
|
-
|
83
|
-
list_value(std::move(other.list_value)) {
|
170
|
+
value_info_(std::move(other.value_info_)) {
|
84
171
|
}
|
85
172
|
|
86
173
|
Value &Value::operator=(const Value &other) {
|
174
|
+
if (this == &other) {
|
175
|
+
return *this;
|
176
|
+
}
|
87
177
|
type_ = other.type_;
|
88
178
|
is_null = other.is_null;
|
89
179
|
value_ = other.value_;
|
90
|
-
|
91
|
-
struct_value = other.struct_value;
|
92
|
-
list_value = other.list_value;
|
180
|
+
value_info_ = other.value_info_;
|
93
181
|
return *this;
|
94
182
|
}
|
95
183
|
|
@@ -97,9 +185,7 @@ Value &Value::operator=(Value &&other) noexcept {
|
|
97
185
|
type_ = std::move(other.type_);
|
98
186
|
is_null = other.is_null;
|
99
187
|
value_ = other.value_;
|
100
|
-
|
101
|
-
struct_value = std::move(other.struct_value);
|
102
|
-
list_value = std::move(other.list_value);
|
188
|
+
value_info_ = std::move(other.value_info_);
|
103
189
|
return *this;
|
104
190
|
}
|
105
191
|
|
@@ -243,7 +329,7 @@ Value Value::MaximumValue(const LogicalType &type) {
|
|
243
329
|
|
244
330
|
Value Value::BOOLEAN(int8_t value) {
|
245
331
|
Value result(LogicalType::BOOLEAN);
|
246
|
-
result.value_.boolean = value
|
332
|
+
result.value_.boolean = bool(value);
|
247
333
|
result.is_null = false;
|
248
334
|
return result;
|
249
335
|
}
|
@@ -512,12 +598,13 @@ Value Value::TIMESTAMP(int32_t year, int32_t month, int32_t day, int32_t hour, i
|
|
512
598
|
Value Value::STRUCT(child_list_t<Value> values) {
|
513
599
|
Value result;
|
514
600
|
child_list_t<LogicalType> child_types;
|
601
|
+
vector<Value> struct_values;
|
515
602
|
for (auto &child : values) {
|
516
603
|
child_types.push_back(make_pair(std::move(child.first), child.second.type()));
|
517
|
-
|
604
|
+
struct_values.push_back(std::move(child.second));
|
518
605
|
}
|
606
|
+
result.value_info_ = make_shared<NestedValueInfo>(std::move(struct_values));
|
519
607
|
result.type_ = LogicalType::STRUCT(std::move(child_types));
|
520
|
-
|
521
608
|
result.is_null = false;
|
522
609
|
return result;
|
523
610
|
}
|
@@ -527,10 +614,7 @@ Value Value::MAP(LogicalType child_type, vector<Value> values) {
|
|
527
614
|
|
528
615
|
result.type_ = LogicalType::MAP(std::move(child_type));
|
529
616
|
result.is_null = false;
|
530
|
-
|
531
|
-
return result;
|
532
|
-
}
|
533
|
-
result.list_value = std::move(values);
|
617
|
+
result.value_info_ = make_shared<NestedValueInfo>(std::move(values));
|
534
618
|
return result;
|
535
619
|
}
|
536
620
|
|
@@ -544,16 +628,17 @@ Value Value::UNION(child_list_t<LogicalType> members, uint8_t tag, Value value)
|
|
544
628
|
Value result;
|
545
629
|
result.is_null = false;
|
546
630
|
// add the tag to the front of the struct
|
547
|
-
|
631
|
+
vector<Value> union_values;
|
632
|
+
union_values.emplace_back(Value::TINYINT(tag));
|
548
633
|
for (idx_t i = 0; i < members.size(); i++) {
|
549
634
|
if (i != tag) {
|
550
|
-
|
635
|
+
union_values.emplace_back(members[i].second);
|
551
636
|
} else {
|
552
|
-
|
637
|
+
union_values.emplace_back(nullptr);
|
553
638
|
}
|
554
639
|
}
|
555
|
-
|
556
|
-
|
640
|
+
union_values[tag + 1] = std::move(value);
|
641
|
+
result.value_info_ = make_shared<NestedValueInfo>(std::move(union_values));
|
557
642
|
result.type_ = LogicalType::UNION(std::move(members));
|
558
643
|
return result;
|
559
644
|
}
|
@@ -570,7 +655,7 @@ Value Value::LIST(vector<Value> values) {
|
|
570
655
|
#endif
|
571
656
|
Value result;
|
572
657
|
result.type_ = LogicalType::LIST(values[0].type());
|
573
|
-
result.
|
658
|
+
result.value_info_ = make_shared<NestedValueInfo>(std::move(values));
|
574
659
|
result.is_null = false;
|
575
660
|
return result;
|
576
661
|
}
|
@@ -588,6 +673,7 @@ Value Value::LIST(LogicalType child_type, vector<Value> values) {
|
|
588
673
|
Value Value::EMPTYLIST(LogicalType child_type) {
|
589
674
|
Value result;
|
590
675
|
result.type_ = LogicalType::LIST(std::move(child_type));
|
676
|
+
result.value_info_ = make_shared<NestedValueInfo>();
|
591
677
|
result.is_null = false;
|
592
678
|
return result;
|
593
679
|
}
|
@@ -595,28 +681,28 @@ Value Value::EMPTYLIST(LogicalType child_type) {
|
|
595
681
|
Value Value::BLOB(const_data_ptr_t data, idx_t len) {
|
596
682
|
Value result(LogicalType::BLOB);
|
597
683
|
result.is_null = false;
|
598
|
-
result.
|
684
|
+
result.value_info_ = make_shared<StringValueInfo>(string((const char *)data, len));
|
599
685
|
return result;
|
600
686
|
}
|
601
687
|
|
602
688
|
Value Value::BLOB(const string &data) {
|
603
689
|
Value result(LogicalType::BLOB);
|
604
690
|
result.is_null = false;
|
605
|
-
result.
|
691
|
+
result.value_info_ = make_shared<StringValueInfo>(Blob::ToBlob(string_t(data)));
|
606
692
|
return result;
|
607
693
|
}
|
608
694
|
|
609
695
|
Value Value::BIT(const_data_ptr_t data, idx_t len) {
|
610
696
|
Value result(LogicalType::BIT);
|
611
697
|
result.is_null = false;
|
612
|
-
result.
|
698
|
+
result.value_info_ = make_shared<StringValueInfo>(string((const char *)data, len));
|
613
699
|
return result;
|
614
700
|
}
|
615
701
|
|
616
702
|
Value Value::BIT(const string &data) {
|
617
703
|
Value result(LogicalType::BIT);
|
618
704
|
result.is_null = false;
|
619
|
-
result.
|
705
|
+
result.value_info_ = make_shared<StringValueInfo>(Bit::ToBit(string_t(data)));
|
620
706
|
return result;
|
621
707
|
}
|
622
708
|
|
@@ -827,7 +913,7 @@ T Value::GetValueInternal() const {
|
|
827
913
|
case LogicalTypeId::DOUBLE:
|
828
914
|
return Cast::Operation<double, T>(value_.double_);
|
829
915
|
case LogicalTypeId::VARCHAR:
|
830
|
-
return Cast::Operation<string_t, T>(
|
916
|
+
return Cast::Operation<string_t, T>(StringValue::Get(*this).c_str());
|
831
917
|
case LogicalTypeId::INTERVAL:
|
832
918
|
return Cast::Operation<interval_t, T>(value_.interval);
|
833
919
|
case LogicalTypeId::DECIMAL:
|
@@ -1100,14 +1186,12 @@ uint64_t Value::GetValueUnsafe() const {
|
|
1100
1186
|
|
1101
1187
|
template <>
|
1102
1188
|
string Value::GetValueUnsafe() const {
|
1103
|
-
|
1104
|
-
return str_value;
|
1189
|
+
return StringValue::Get(*this);
|
1105
1190
|
}
|
1106
1191
|
|
1107
1192
|
template <>
|
1108
1193
|
DUCKDB_API string_t Value::GetValueUnsafe() const {
|
1109
|
-
|
1110
|
-
return string_t(str_value);
|
1194
|
+
return string_t(StringValue::Get(*this));
|
1111
1195
|
}
|
1112
1196
|
|
1113
1197
|
template <>
|
@@ -1258,7 +1342,7 @@ string Value::ToString() const {
|
|
1258
1342
|
if (IsNull()) {
|
1259
1343
|
return "NULL";
|
1260
1344
|
}
|
1261
|
-
return DefaultCastAs(LogicalType::VARCHAR)
|
1345
|
+
return StringValue::Get(DefaultCastAs(LogicalType::VARCHAR));
|
1262
1346
|
}
|
1263
1347
|
|
1264
1348
|
string Value::ToSQLString() const {
|
@@ -1283,11 +1367,12 @@ string Value::ToSQLString() const {
|
|
1283
1367
|
case LogicalTypeId::STRUCT: {
|
1284
1368
|
string ret = "{";
|
1285
1369
|
auto &child_types = StructType::GetChildTypes(type_);
|
1286
|
-
|
1370
|
+
auto &struct_values = StructValue::GetChildren(*this);
|
1371
|
+
for (size_t i = 0; i < struct_values.size(); i++) {
|
1287
1372
|
auto &name = child_types[i].first;
|
1288
|
-
auto &child =
|
1373
|
+
auto &child = struct_values[i];
|
1289
1374
|
ret += "'" + name + "': " + child.ToSQLString();
|
1290
|
-
if (i <
|
1375
|
+
if (i < struct_values.size() - 1) {
|
1291
1376
|
ret += ", ";
|
1292
1377
|
}
|
1293
1378
|
}
|
@@ -1312,10 +1397,11 @@ string Value::ToSQLString() const {
|
|
1312
1397
|
}
|
1313
1398
|
case LogicalTypeId::LIST: {
|
1314
1399
|
string ret = "[";
|
1315
|
-
|
1316
|
-
|
1400
|
+
auto &list_values = ListValue::GetChildren(*this);
|
1401
|
+
for (size_t i = 0; i < list_values.size(); i++) {
|
1402
|
+
auto &child = list_values[i];
|
1317
1403
|
ret += child.ToSQLString();
|
1318
|
-
if (i <
|
1404
|
+
if (i < list_values.size() - 1) {
|
1319
1405
|
ret += ", ";
|
1320
1406
|
}
|
1321
1407
|
}
|
@@ -1379,8 +1465,12 @@ double DoubleValue::Get(const Value &value) {
|
|
1379
1465
|
}
|
1380
1466
|
|
1381
1467
|
const string &StringValue::Get(const Value &value) {
|
1468
|
+
if (value.is_null) {
|
1469
|
+
throw InternalException("Calling StringValue::Get on a NULL value");
|
1470
|
+
}
|
1382
1471
|
D_ASSERT(value.type().InternalType() == PhysicalType::VARCHAR);
|
1383
|
-
|
1472
|
+
D_ASSERT(value.value_info_);
|
1473
|
+
return value.value_info_->Get<StringValueInfo>().GetString();
|
1384
1474
|
}
|
1385
1475
|
|
1386
1476
|
date_t DateValue::Get(const Value &value) {
|
@@ -1400,13 +1490,21 @@ interval_t IntervalValue::Get(const Value &value) {
|
|
1400
1490
|
}
|
1401
1491
|
|
1402
1492
|
const vector<Value> &StructValue::GetChildren(const Value &value) {
|
1493
|
+
if (value.is_null) {
|
1494
|
+
throw InternalException("Calling StructValue::GetChildren on a NULL value");
|
1495
|
+
}
|
1403
1496
|
D_ASSERT(value.type().InternalType() == PhysicalType::STRUCT);
|
1404
|
-
|
1497
|
+
D_ASSERT(value.value_info_);
|
1498
|
+
return value.value_info_->Get<NestedValueInfo>().GetValues();
|
1405
1499
|
}
|
1406
1500
|
|
1407
1501
|
const vector<Value> &ListValue::GetChildren(const Value &value) {
|
1502
|
+
if (value.is_null) {
|
1503
|
+
throw InternalException("Calling ListValue::GetChildren on a NULL value");
|
1504
|
+
}
|
1408
1505
|
D_ASSERT(value.type().InternalType() == PhysicalType::LIST);
|
1409
|
-
|
1506
|
+
D_ASSERT(value.value_info_);
|
1507
|
+
return value.value_info_->Get<NestedValueInfo>().GetValues();
|
1410
1508
|
}
|
1411
1509
|
|
1412
1510
|
const Value &UnionValue::GetValue(const Value &value) {
|
@@ -1559,9 +1657,7 @@ bool Value::TryCastAs(CastFunctionSet &set, GetCastFunctionInput &get_input, con
|
|
1559
1657
|
type_ = target_type;
|
1560
1658
|
is_null = new_value.is_null;
|
1561
1659
|
value_ = new_value.value_;
|
1562
|
-
|
1563
|
-
struct_value = new_value.struct_value;
|
1564
|
-
list_value = new_value.list_value;
|
1660
|
+
value_info_ = std::move(new_value.value_info_);
|
1565
1661
|
return true;
|
1566
1662
|
}
|
1567
1663
|
|
@@ -1627,7 +1723,7 @@ void Value::Serialize(Serializer &main_serializer) const {
|
|
1627
1723
|
serializer.Write<interval_t>(value_.interval);
|
1628
1724
|
break;
|
1629
1725
|
case PhysicalType::VARCHAR:
|
1630
|
-
serializer.WriteString(
|
1726
|
+
serializer.WriteString(StringValue::Get(*this));
|
1631
1727
|
break;
|
1632
1728
|
default: {
|
1633
1729
|
Vector v(*this);
|
@@ -1691,7 +1787,7 @@ Value Value::Deserialize(Deserializer &main_source) {
|
|
1691
1787
|
new_value.value_.interval = source.Read<interval_t>();
|
1692
1788
|
break;
|
1693
1789
|
case PhysicalType::VARCHAR:
|
1694
|
-
new_value.
|
1790
|
+
new_value.value_info_ = make_shared<StringValueInfo>(source.Read<string>());
|
1695
1791
|
break;
|
1696
1792
|
default: {
|
1697
1793
|
Vector v(type);
|
@@ -1747,8 +1843,8 @@ bool Value::ValuesAreEqual(CastFunctionSet &set, GetCastFunctionInput &get_input
|
|
1747
1843
|
}
|
1748
1844
|
case LogicalTypeId::VARCHAR: {
|
1749
1845
|
auto other = result_value.CastAs(set, get_input, LogicalType::VARCHAR);
|
1750
|
-
string left = SanitizeValue(other
|
1751
|
-
string right = SanitizeValue(value
|
1846
|
+
string left = SanitizeValue(StringValue::Get(other));
|
1847
|
+
string right = SanitizeValue(StringValue::Get(value));
|
1752
1848
|
return left == right;
|
1753
1849
|
}
|
1754
1850
|
default:
|
@@ -73,9 +73,9 @@ void Vector::Reference(const Value &value) {
|
|
73
73
|
auto struct_buffer = make_unique<VectorStructBuffer>();
|
74
74
|
auto &child_types = StructType::GetChildTypes(value.type());
|
75
75
|
auto &child_vectors = struct_buffer->GetChildren();
|
76
|
-
auto &value_children = StructValue::GetChildren(value);
|
77
76
|
for (idx_t i = 0; i < child_types.size(); i++) {
|
78
|
-
auto vector =
|
77
|
+
auto vector =
|
78
|
+
make_unique<Vector>(value.IsNull() ? Value(child_types[i].second) : StructValue::GetChildren(value)[i]);
|
79
79
|
child_vectors.push_back(std::move(vector));
|
80
80
|
}
|
81
81
|
auxiliary = std::move(struct_buffer);
|
@@ -372,15 +372,18 @@ void Vector::SetValue(idx_t index, const Value &val) {
|
|
372
372
|
D_ASSERT(GetVectorType() == VectorType::CONSTANT_VECTOR || GetVectorType() == VectorType::FLAT_VECTOR);
|
373
373
|
|
374
374
|
auto &children = StructVector::GetEntries(*this);
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
375
|
+
if (val.IsNull()) {
|
376
|
+
for (size_t i = 0; i < children.size(); i++) {
|
377
|
+
auto &vec_child = children[i];
|
378
|
+
vec_child->SetValue(index, Value());
|
379
|
+
}
|
380
|
+
} else {
|
381
|
+
auto &val_children = StructValue::GetChildren(val);
|
382
|
+
D_ASSERT(children.size() == val_children.size());
|
383
|
+
for (size_t i = 0; i < children.size(); i++) {
|
384
|
+
auto &vec_child = children[i];
|
380
385
|
auto &struct_child = val_children[i];
|
381
386
|
vec_child->SetValue(index, struct_child);
|
382
|
-
} else {
|
383
|
-
vec_child->SetValue(index, Value());
|
384
387
|
}
|
385
388
|
}
|
386
389
|
break;
|
@@ -1376,7 +1379,7 @@ string_t StringVector::AddString(Vector &vector, const string &data) {
|
|
1376
1379
|
}
|
1377
1380
|
|
1378
1381
|
string_t StringVector::AddString(Vector &vector, string_t data) {
|
1379
|
-
D_ASSERT(vector.GetType().id() == LogicalTypeId::VARCHAR);
|
1382
|
+
D_ASSERT(vector.GetType().id() == LogicalTypeId::VARCHAR || vector.GetType().id() == LogicalTypeId::BIT);
|
1380
1383
|
if (data.IsInlined()) {
|
1381
1384
|
// string will be inlined: no need to store in string heap
|
1382
1385
|
return data;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "duckdb/execution/column_binding_resolver.hpp"
|
2
2
|
|
3
3
|
#include "duckdb/planner/operator/logical_comparison_join.hpp"
|
4
|
+
#include "duckdb/planner/operator/logical_any_join.hpp"
|
4
5
|
#include "duckdb/planner/operator/logical_create_index.hpp"
|
5
6
|
#include "duckdb/planner/operator/logical_delim_join.hpp"
|
6
7
|
#include "duckdb/planner/operator/logical_insert.hpp"
|
@@ -46,6 +47,11 @@ void ColumnBindingResolver::VisitOperator(LogicalOperator &op) {
|
|
46
47
|
// this operator
|
47
48
|
VisitOperatorChildren(op);
|
48
49
|
bindings = op.GetColumnBindings();
|
50
|
+
auto &any_join = (LogicalAnyJoin &)op;
|
51
|
+
if (any_join.join_type == JoinType::SEMI || any_join.join_type == JoinType::ANTI) {
|
52
|
+
auto right_bindings = op.children[1]->GetColumnBindings();
|
53
|
+
bindings.insert(bindings.end(), right_bindings.begin(), right_bindings.end());
|
54
|
+
}
|
49
55
|
VisitOperatorExpressions(op);
|
50
56
|
return;
|
51
57
|
} else if (op.type == LogicalOperatorType::LOGICAL_CREATE_INDEX) {
|
@@ -4,14 +4,13 @@
|
|
4
4
|
#include "duckdb/planner/expression/bound_aggregate_expression.hpp"
|
5
5
|
#include "duckdb/planner/expression/bound_reference_expression.hpp"
|
6
6
|
#include "duckdb/storage/buffer_manager.hpp"
|
7
|
-
#include "duckdb/storage/statistics/numeric_statistics.hpp"
|
8
7
|
|
9
8
|
namespace duckdb {
|
10
9
|
|
11
10
|
PhysicalPerfectHashAggregate::PhysicalPerfectHashAggregate(ClientContext &context, vector<LogicalType> types_p,
|
12
11
|
vector<unique_ptr<Expression>> aggregates_p,
|
13
12
|
vector<unique_ptr<Expression>> groups_p,
|
14
|
-
vector<unique_ptr<BaseStatistics>> group_stats,
|
13
|
+
const vector<unique_ptr<BaseStatistics>> &group_stats,
|
15
14
|
vector<idx_t> required_bits_p, idx_t estimated_cardinality)
|
16
15
|
: PhysicalOperator(PhysicalOperatorType::PERFECT_HASH_GROUP_BY, std::move(types_p), estimated_cardinality),
|
17
16
|
groups(std::move(groups_p)), aggregates(std::move(aggregates_p)), required_bits(std::move(required_bits_p)) {
|
@@ -19,9 +18,9 @@ PhysicalPerfectHashAggregate::PhysicalPerfectHashAggregate(ClientContext &contex
|
|
19
18
|
group_minima.reserve(group_stats.size());
|
20
19
|
for (auto &stats : group_stats) {
|
21
20
|
D_ASSERT(stats);
|
22
|
-
auto &nstats =
|
23
|
-
D_ASSERT(
|
24
|
-
group_minima.push_back(
|
21
|
+
auto &nstats = *stats;
|
22
|
+
D_ASSERT(NumericStats::HasMin(nstats));
|
23
|
+
group_minima.push_back(NumericStats::Min(nstats));
|
25
24
|
}
|
26
25
|
for (auto &expr : groups) {
|
27
26
|
group_types.push_back(expr->return_type);
|