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

huajianlan pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 1236cfd1598 [fix](Nereids) fix Is Cached is not Yes in Profile when 
enable_sql_cache=true (#42032) (#42034)
1236cfd1598 is described below

commit 1236cfd1598fc002515c58d913f166adc16cf313
Author: 924060929 <924060...@qq.com>
AuthorDate: Fri Oct 18 16:17:15 2024 +0800

    [fix](Nereids) fix Is Cached is not Yes in Profile when 
enable_sql_cache=true (#42032) (#42034)
    
    fix `Is  Cached` is not Yes in Profile when enable_sql_cache=true, 
introduced by #33262
---
 .../java/org/apache/doris/qe/StmtExecutor.java     |  8 +++++
 .../cache/parse_sql_from_sql_cache.groovy          | 36 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index c140ff064e4..83a6a0afb8a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -1744,6 +1744,14 @@ public class StmtExecutor {
             return;
         }
 
+        if (parsedStmt instanceof LogicalPlanAdapter) {
+            LogicalPlanAdapter logicalPlanAdapter = (LogicalPlanAdapter) 
parsedStmt;
+            LogicalPlan logicalPlan = logicalPlanAdapter.getLogicalPlan();
+            if (logicalPlan instanceof 
org.apache.doris.nereids.trees.plans.algebra.SqlCache) {
+                isCached = true;
+            }
+        }
+
         // handle selects that fe can do without be, so we can make sql tools 
happy, especially the setup step.
         // TODO FE not support doris field type conversion to arrow field type.
         if (!context.getConnectType().equals(ConnectType.ARROW_FLIGHT_SQL)
diff --git 
a/regression-test/suites/nereids_p0/cache/parse_sql_from_sql_cache.groovy 
b/regression-test/suites/nereids_p0/cache/parse_sql_from_sql_cache.groovy
index 4bf5c277d21..b213c4ba300 100644
--- a/regression-test/suites/nereids_p0/cache/parse_sql_from_sql_cache.groovy
+++ b/regression-test/suites/nereids_p0/cache/parse_sql_from_sql_cache.groovy
@@ -736,6 +736,42 @@ suite("parse_sql_from_sql_cache") {
             sql "select /*+SET_VAR(disable_nereids_rules='')*/ /*comment1*/ * 
from test_use_plan_cache22 order by 1, 2"
 
             assertHasCache "select /*+SET_VAR(disable_nereids_rules='')*/ 
/*comment2*/ * from test_use_plan_cache22 order by 1, 2"
+        }),
+        extraThread("is_cache_profile", {
+            createTestTable "test_use_plan_cache23"
+
+            // after partition changed 10s, the sql cache can be used
+            sleep(10000)
+
+            sql "set enable_nereids_planner=true"
+            sql "set enable_fallback_to_original_planner=false"
+            sql "set enable_sql_cache=true"
+
+            int randomInt = Math.random() * 2000000000
+            sql "select ${randomInt} from test_use_plan_cache23"
+            profile("sql_cache_23_${randomInt}") {
+                run {
+                    sql "/* sql_cache_23_${randomInt} */ select ${randomInt} 
from test_use_plan_cache23"
+                }
+
+                check { profileString, exception ->
+                    log.info(profileString)
+                    assertTrue(profileString.contains("Is  Cached:  Yes"))
+                }
+            }
+
+            randomInt = Math.random() * 2000000000
+            sql "select * from (select $randomInt as id)a"
+            profile("sql_cache_23_${randomInt}_2") {
+                run {
+                    sql "/* sql_cache_23_${randomInt}_2 */ select * from 
(select $randomInt as id)a"
+                }
+
+                check { profileString, exception ->
+                    log.info(profileString)
+                    assertTrue(profileString.contains("Is  Cached:  Yes"))
+                }
+            }
         })
     ).get()
 }


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

Reply via email to