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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 4f1aebb8e8f (topN)runtime_predicate is only triggered when the column 
name is obtained (#28419)
4f1aebb8e8f is described below

commit 4f1aebb8e8fc98d502429f3ab5952e2284f68065
Author: Yoko <53637394+tomay...@users.noreply.github.com>
AuthorDate: Thu Dec 21 18:08:23 2023 +0800

    (topN)runtime_predicate is only triggered when the column name is obtained 
(#28419)
    
    Issue Number: close #27485
---
 be/src/vec/exec/vsort_node.cpp                     | 12 ++++++----
 .../data/topn_optimize/topn_runtime_predicate.out  |  8 +++++++
 .../topn_optimize/topn_runtime_predicate.groovy    | 28 ++++++++++++++++++++++
 3 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/be/src/vec/exec/vsort_node.cpp b/be/src/vec/exec/vsort_node.cpp
index 7c266a37460..7fd9ac274b1 100644
--- a/be/src/vec/exec/vsort_node.cpp
+++ b/be/src/vec/exec/vsort_node.cpp
@@ -148,11 +148,13 @@ Status VSortNode::sink(RuntimeState* state, 
vectorized::Block* input_block, bool
             if (!new_top.is_null() && (old_top.is_null() || new_top != 
old_top)) {
                 auto& sort_description = _sorter->get_sort_description();
                 auto col = 
input_block->get_by_position(sort_description[0].column_number);
-                bool is_reverse = sort_description[0].direction < 0;
-                auto query_ctx = state->get_query_ctx();
-                RETURN_IF_ERROR(
-                        query_ctx->get_runtime_predicate().update(new_top, 
col.name, is_reverse));
-                old_top = std::move(new_top);
+                if (!col.name.empty()) {
+                    bool is_reverse = sort_description[0].direction < 0;
+                    auto* query_ctx = state->get_query_ctx();
+                    
RETURN_IF_ERROR(query_ctx->get_runtime_predicate().update(new_top, col.name,
+                                                                              
is_reverse));
+                    old_top = std::move(new_top);
+                }
             }
         }
         if (!_reuse_mem) {
diff --git a/regression-test/data/topn_optimize/topn_runtime_predicate.out 
b/regression-test/data/topn_optimize/topn_runtime_predicate.out
new file mode 100644
index 00000000000..64ac08e3cf4
--- /dev/null
+++ b/regression-test/data/topn_optimize/topn_runtime_predicate.out
@@ -0,0 +1,8 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+0
+0
+1
+
+-- !select --
+0
diff --git a/regression-test/suites/topn_optimize/topn_runtime_predicate.groovy 
b/regression-test/suites/topn_optimize/topn_runtime_predicate.groovy
new file mode 100644
index 00000000000..3a84c09ddaa
--- /dev/null
+++ b/regression-test/suites/topn_optimize/topn_runtime_predicate.groovy
@@ -0,0 +1,28 @@
+// 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("topn_runtime_predicate") {
+    def tableName = "topn_runtime_predicate"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql "CREATE  TABLE if NOT EXISTS ${tableName} (c1 INT) DUPLICATE KEY(c1) 
DISTRIBUTED BY HASH (c1) BUCKETS 1 PROPERTIES ('replication_num' = '1');"
+    sql """insert into ${tableName} values  (1),
+                                                                               
         (0),
+                                                                               
         (0)"""
+    qt_select " select * from (select cast(c1 as int) t1 from ${tableName}) t  
order by t1"
+    qt_select " select * from (select cast(c1 as int) t1 from ${tableName}) t  
order by t1 limit 1"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to