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

lihaopeng 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 e9a34e4f332 [Fix](QueryCache) Fix cache order different may cause 
error (#47961)
e9a34e4f332 is described below

commit e9a34e4f332f2c69888d2d314db4b15aa967a041
Author: HappenLee <happen...@selectdb.com>
AuthorDate: Tue Feb 18 12:00:04 2025 +0800

    [Fix](QueryCache) Fix cache order different may cause error (#47961)
    
    the origin judge may cause the need reorder judge error:
    ```
       bool need_reorder = _slot_orders.size() != hit_cache_slot_orders->size();
            if (!need_reorder) {
                for (int i = 0; i < _slot_orders.size(); ++i) {
                    need_reorder = _slot_orders[i] != 
(*hit_cache_slot_orders)[i];
                }
            }
    ```
---
 be/src/pipeline/exec/cache_source_operator.cpp     |   9 +-------
 .../data/query_p0/cache/query_cache.out            | Bin 275 -> 365 bytes
 .../suites/query_p0/cache/query_cache.groovy       |  24 ++++++++++++++++++++-
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/be/src/pipeline/exec/cache_source_operator.cpp 
b/be/src/pipeline/exec/cache_source_operator.cpp
index cace8465fc2..20fd247c136 100644
--- a/be/src/pipeline/exec/cache_source_operator.cpp
+++ b/be/src/pipeline/exec/cache_source_operator.cpp
@@ -70,14 +70,7 @@ Status CacheSourceLocalState::init(RuntimeState* state, 
LocalStateInfo& info) {
         _hit_cache_results = _query_cache_handle.get_cache_result();
         auto hit_cache_slot_orders = 
_query_cache_handle.get_cache_slot_orders();
 
-        bool need_reorder = _slot_orders.size() != 
hit_cache_slot_orders->size();
-        if (!need_reorder) {
-            for (int i = 0; i < _slot_orders.size(); ++i) {
-                need_reorder = _slot_orders[i] != (*hit_cache_slot_orders)[i];
-            }
-        }
-
-        if (need_reorder) {
+        if (_slot_orders != *hit_cache_slot_orders) {
             for (auto slot_id : _slot_orders) {
                 auto find_res = std::find(hit_cache_slot_orders->begin(),
                                           hit_cache_slot_orders->end(), 
slot_id);
diff --git a/regression-test/data/query_p0/cache/query_cache.out 
b/regression-test/data/query_p0/cache/query_cache.out
index 5cfa581b3bf..90a8086bb69 100644
Binary files a/regression-test/data/query_p0/cache/query_cache.out and 
b/regression-test/data/query_p0/cache/query_cache.out differ
diff --git a/regression-test/suites/query_p0/cache/query_cache.groovy 
b/regression-test/suites/query_p0/cache/query_cache.groovy
index 997453f1819..e448a8978a0 100644
--- a/regression-test/suites/query_p0/cache/query_cache.groovy
+++ b/regression-test/suites/query_p0/cache/query_cache.groovy
@@ -160,4 +160,26 @@ suite("query_cache") {
         GROUP BY field3
     """
 
-} 
\ No newline at end of file
+    order_qt_query_cache7 """
+        SELECT
+        col_int_undef_signed,
+            MIN(`col_int_undef_signed`) AS field1,
+            MAX(`col_int_undef_signed`) AS field2,
+            COUNT(`col_int_undef_signed`) AS field3,
+            SUM(`col_int_undef_signed`) AS field4
+        FROM ${tableName}
+        GROUP BY col_int_undef_signed
+    """
+
+    // reorder the order_qt_query_cache7 select list to test the cache hit
+    order_qt_query_cache8 """
+ SELECT
+    COUNT(`col_int_undef_signed`) AS field3,  -- Count of col_int_undef_signed 
(Original field3)
+    col_int_undef_signed,                      -- The original unsigned 
integer column (Original col_int_undef_signed)
+    SUM(`col_int_undef_signed`) AS field4,     -- Sum of col_int_undef_signed 
(Original field4)
+    MIN(`col_int_undef_signed`) AS field1,     -- Minimum value of 
col_int_undef_signed (Original field1)
+    MAX(`col_int_undef_signed`) AS field2      -- Maximum value of 
col_int_undef_signed (Original field2). Note: Trailing comma removed to avoid 
syntax error.
+FROM ${tableName}
+GROUP BY col_int_undef_signed;
+    """
+} 


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

Reply via email to