Skip to content

Commit

Permalink
fix Profile.isCached
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Oct 17, 2024
1 parent 36dd6f1 commit 78e2cdd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,14 @@ private void handleQueryStmt() throws Exception {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,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()
}

0 comments on commit 78e2cdd

Please sign in to comment.