You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by kx...@apache.org on 2023/06/06 15:15:23 UTC

[doris] 21/36: [fix](sequence) value predicates shouldn't be push down when has sequence column (#20408)

This is an automated email from the ASF dual-hosted git repository.

kxiao pushed a commit to branch branch-2.0-beta
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 0b16cde515389ef20f3cc3e5e406337e7dfe53a6
Author: Xin Liao <li...@126.com>
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 ab69aea140..2df50d1177 100644
--- a/be/src/olap/rowset/beta_rowset_reader.cpp
+++ b/be/src/olap/rowset/beta_rowset_reader.cpp
@@ -304,10 +304,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: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org