Merge pull request #43387 from ClickHouse/fix_default_value_used_in_row_level_filter

Fix default value used in row level filter
This commit is contained in:
Anton Popov 2022-11-22 01:46:45 +01:00 committed by GitHub
commit 0479d8d9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 2 deletions

View File

@ -315,7 +315,9 @@ MergeTreeReadTaskColumns getReadTaskColumns(
/// 1. Columns for row level filter
if (prewhere_info->row_level_filter)
{
Names row_filter_column_names = prewhere_info->row_level_filter->getRequiredColumnsNames();
Names row_filter_column_names = prewhere_info->row_level_filter->getRequiredColumnsNames();
injectRequiredColumns(
data_part_info_for_reader, storage_snapshot, with_subcolumns, row_filter_column_names);
result.pre_columns.push_back(storage_snapshot->getColumnsByNames(options, row_filter_column_names));
pre_name_set.insert(row_filter_column_names.begin(), row_filter_column_names.end());
}
@ -323,7 +325,7 @@ MergeTreeReadTaskColumns getReadTaskColumns(
/// 2. Columns for prewhere
Names all_pre_column_names = prewhere_info->prewhere_actions->getRequiredColumnsNames();
const auto injected_pre_columns = injectRequiredColumns(
injectRequiredColumns(
data_part_info_for_reader, storage_snapshot, with_subcolumns, all_pre_column_names);
for (const auto & name : all_pre_column_names)

View File

@ -0,0 +1,16 @@
-- { echoOn }
SELECT a, c FROM test_rlp WHERE c%2 == 0 AND b < 5;
0 10
2 12
4 14
DROP POLICY IF EXISTS test_rlp_policy ON test_rlp;
CREATE ROW POLICY test_rlp_policy ON test_rlp FOR SELECT USING c%2 == 0 TO default;
SELECT a, c FROM test_rlp WHERE b < 5 SETTINGS optimize_move_to_prewhere = 0;
0 10
2 12
4 14
SELECT a, c FROM test_rlp PREWHERE b < 5;
0 10
2 12
4 14

View File

@ -0,0 +1,25 @@
DROP TABLE IF EXISTS test_rlp;
CREATE TABLE test_rlp (a Int32, b Int32) ENGINE=MergeTree() ORDER BY a SETTINGS index_granularity=5;
INSERT INTO test_rlp SELECT number, number FROM numbers(15);
ALTER TABLE test_rlp ADD COLUMN c Int32 DEFAULT b+10;
-- { echoOn }
SELECT a, c FROM test_rlp WHERE c%2 == 0 AND b < 5;
DROP POLICY IF EXISTS test_rlp_policy ON test_rlp;
CREATE ROW POLICY test_rlp_policy ON test_rlp FOR SELECT USING c%2 == 0 TO default;
SELECT a, c FROM test_rlp WHERE b < 5 SETTINGS optimize_move_to_prewhere = 0;
SELECT a, c FROM test_rlp PREWHERE b < 5;
-- { echoOff }
DROP POLICY test_rlp_policy ON test_rlp;
DROP TABLE test_rlp;