This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit 9b684d52e4c31136309f45da2648e53ab8fe069d Author: Xin Liao <[email protected]> AuthorDate: Mon Jun 5 19:18:34 2023 +0800 [fix](sequence) value predicates shouldn't be push down when has sequence column (#20408) * (fix)[sequence] value predicates shouldn't be push down when has sequence column * add case --- be/src/olap/rowset/beta_rowset_reader.cpp | 6 +- .../unique/test_unique_value_predicate.out | 45 +++++++++ .../unique/test_unique_value_predicate.groovy | 111 +++++++++++++++++++++ 3 files changed, 160 insertions(+), 2 deletions(-) diff --git a/be/src/olap/rowset/beta_rowset_reader.cpp b/be/src/olap/rowset/beta_rowset_reader.cpp index fa1f965ea2..24c1265049 100644 --- a/be/src/olap/rowset/beta_rowset_reader.cpp +++ b/be/src/olap/rowset/beta_rowset_reader.cpp @@ -384,10 +384,12 @@ Status BetaRowsetReader::next_block_view(vectorized::BlockView* block_view) { bool BetaRowsetReader::_should_push_down_value_predicates() const { // if unique table with rowset [0-x] or [0-1] [2-y] [...], - // value column predicates can be pushdown on rowset [0-x] or [2-y], [2-y] must be compaction and not overlapping + // value column predicates can be pushdown on rowset [0-x] or [2-y], [2-y] + // must be compaction, not overlapping and don't have sequence column return _rowset->keys_type() == UNIQUE_KEYS && (((_rowset->start_version() == 0 || _rowset->start_version() == 2) && - !_rowset->_rowset_meta->is_segments_overlapping()) || + !_rowset->_rowset_meta->is_segments_overlapping() && + _context->sequence_id_idx == -1) || _context->enable_unique_key_merge_on_write); } diff --git a/regression-test/data/data_model_p0/unique/test_unique_value_predicate.out b/regression-test/data/data_model_p0/unique/test_unique_value_predicate.out new file mode 100644 index 0000000000..0fe421460f --- /dev/null +++ b/regression-test/data/data_model_p0/unique/test_unique_value_predicate.out @@ -0,0 +1,45 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +0 1 test char 2000-01-01 + +-- !select -- +0 1 test char 2000-01-01 + +-- !select -- + +-- !select -- +0 1 test char 2000-01-01 + +-- !select -- +0 2 test int 2000-02-02 + +-- !select -- +0 2 test int 2000-02-02 + +-- !select -- +0 2 test int 2000-02-02 + +-- !select -- + +-- !select -- +0 1 test char 2000-01-01 + +-- !select -- +0 1 test char 2000-01-01 + +-- !select -- + +-- !select -- +0 1 test char 2000-01-01 + +-- !select -- +0 2 test int 2000-02-02 + +-- !select -- +0 2 test int 2000-02-02 + +-- !select -- +0 2 test int 2000-02-02 + +-- !select -- + diff --git a/regression-test/suites/data_model_p0/unique/test_unique_value_predicate.groovy b/regression-test/suites/data_model_p0/unique/test_unique_value_predicate.groovy new file mode 100644 index 0000000000..c5a1e5b4ca --- /dev/null +++ b/regression-test/suites/data_model_p0/unique/test_unique_value_predicate.groovy @@ -0,0 +1,111 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_unique_value_predicate") { + // test uniq table + def tbName = "test_uniq_value_predicate" + // mor without seq + sql "DROP TABLE IF EXISTS ${tbName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName} ( + k int, + int_value int, + char_value char(10), + date_value date + ) + UNIQUE KEY(k) + DISTRIBUTED BY HASH(k) BUCKETS 1 + properties("replication_num" = "1", + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "false"); + """ + sql "insert into ${tbName} values(0, 2, 'test int', '2000-02-02')" + sql "insert into ${tbName} values(0, 1, 'test char', '2000-01-01')" + qt_select "select * from ${tbName}" + qt_select "select * from ${tbName} where k = 0" + qt_select "select * from ${tbName} where k = 0 && int_value = 2" + qt_select "select * from ${tbName} where k = 0 && int_value = 1" + + // mor with seq + sql "DROP TABLE IF EXISTS ${tbName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName} ( + k int, + int_value int, + char_value char(10), + date_value date + ) + UNIQUE KEY(k) + DISTRIBUTED BY HASH(k) BUCKETS 1 + properties("replication_num" = "1", + "function_column.sequence_col" = "int_value", + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "false"); + """ + sql "insert into ${tbName} values(0, 2, 'test int', '2000-02-02')" + sql "insert into ${tbName} values(0, 1, 'test char', '2000-01-01')" + qt_select "select * from ${tbName}" + qt_select "select * from ${tbName} where k = 0" + qt_select "select * from ${tbName} where k = 0 && int_value = 2" + qt_select "select * from ${tbName} where k = 0 && int_value = 1" + + // mow without seq + sql "DROP TABLE IF EXISTS ${tbName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName} ( + k int, + int_value int, + char_value char(10), + date_value date + ) + UNIQUE KEY(k) + DISTRIBUTED BY HASH(k) BUCKETS 1 + properties("replication_num" = "1", + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "true"); + """ + sql "insert into ${tbName} values(0, 2, 'test int', '2000-02-02')" + sql "insert into ${tbName} values(0, 1, 'test char', '2000-01-01')" + qt_select "select * from ${tbName}" + qt_select "select * from ${tbName} where k = 0" + qt_select "select * from ${tbName} where k = 0 && int_value = 2" + qt_select "select * from ${tbName} where k = 0 && int_value = 1" + + // mow with seq + sql "DROP TABLE IF EXISTS ${tbName}" + sql """ + CREATE TABLE IF NOT EXISTS ${tbName} ( + k int, + int_value int, + char_value char(10), + date_value date + ) + UNIQUE KEY(k) + DISTRIBUTED BY HASH(k) BUCKETS 1 + properties("replication_num" = "1", + "function_column.sequence_col" = "int_value", + "disable_auto_compaction" = "true", + "enable_unique_key_merge_on_write" = "true"); + """ + sql "insert into ${tbName} values(0, 2, 'test int', '2000-02-02')" + sql "insert into ${tbName} values(0, 1, 'test char', '2000-01-01')" + qt_select "select * from ${tbName}" + qt_select "select * from ${tbName} where k = 0" + qt_select "select * from ${tbName} where k = 0 && int_value = 2" + qt_select "select * from ${tbName} where k = 0 && int_value = 1" + sql "DROP TABLE ${tbName}" +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
