This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 50475fa936f branch-3.0: [test](mtmv) Auto calc the value of
sync_cbo_rewrite variable to makesure the same test code in different version
(#43331)
50475fa936f is described below
commit 50475fa936fa2d3328ccd4151aaddc5f1940d684
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Nov 14 19:10:30 2024 +0800
branch-3.0: [test](mtmv) Auto calc the value of sync_cbo_rewrite variable
to makesure the same test code in different version (#43331)
Cherry-picked from #42279
Co-authored-by: seawinde <[email protected]>
---
.../org/apache/doris/nereids/NereidsPlanner.java | 4 +-
.../exploration/mv/MaterializationContext.java | 3 +-
.../org/apache/doris/regression/suite/Suite.groovy | 67 +++++++++++++++-------
3 files changed, 50 insertions(+), 24 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
index 7ea92ee73b3..9ceecde9950 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/NereidsPlanner.java
@@ -595,11 +595,11 @@ public class NereidsPlanner extends Planner {
ExplainLevel explainLevel = getExplainLevel(explainOptions);
String plan = "";
String mvSummary = "";
- if (this.getPhysicalPlan() != null && cascadesContext != null) {
+ if ((this.getPhysicalPlan() != null || this.getOptimizedPlan() !=
null) && cascadesContext != null) {
mvSummary = cascadesContext.getMaterializationContexts().isEmpty()
? "" :
"\n\n========== MATERIALIZATIONS ==========\n"
+
MaterializationContext.toSummaryString(cascadesContext.getMaterializationContexts(),
- this.getPhysicalPlan());
+ this.getPhysicalPlan() == null ?
this.getOptimizedPlan() : this.getPhysicalPlan());
}
switch (explainLevel) {
case PARSED_PLAN:
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializationContext.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializationContext.java
index 609125280de..df535d59d87 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializationContext.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializationContext.java
@@ -35,7 +35,6 @@ import org.apache.doris.nereids.trees.plans.ObjectId;
import org.apache.doris.nereids.trees.plans.Plan;
import org.apache.doris.nereids.trees.plans.algebra.Relation;
import
org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel;
-import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
import org.apache.doris.nereids.trees.plans.physical.PhysicalRelation;
import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanVisitor;
import org.apache.doris.statistics.ColumnStatistic;
@@ -348,7 +347,7 @@ public abstract class MaterializationContext {
* ToSummaryString, this contains only summary info.
*/
public static String toSummaryString(List<MaterializationContext>
materializationContexts,
- PhysicalPlan physicalPlan) {
+ Plan physicalPlan) {
if (materializationContexts.isEmpty()) {
return "";
}
diff --git
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
index c7ebb9d8316..0854b541ff6 100644
---
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
+++
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
@@ -1757,6 +1757,17 @@ class Suite implements GroovyInterceptable {
return result.values().toList()
}
+ // enable_sync_mv_cost_based_rewrite is true or not
+ boolean enable_sync_mv_cost_based_rewrite () {
+ def showVariable = "show variables like
'enable_sync_mv_cost_based_rewrite';"
+ List<List<Object>> result = sql(showVariable)
+ logger.info("enable_sync_mv_cost_based_rewrite = " + result)
+ if (result.isEmpty()) {
+ return false;
+ }
+ return Boolean.parseBoolean(result.get(0).get(1));
+ }
+
// Given tables to decide whether the table partition row count statistic
is ready or not
boolean is_partition_statistics_ready(db, tables) {
boolean isReady = true;
@@ -1836,12 +1847,14 @@ class Suite implements GroovyInterceptable {
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
// is_partition_statistics_ready is the bool value which identifying if
partition row count is valid or not
// if true, check if chosen by cbo or doesn't check
- def mv_rewrite_success = { query_sql, mv_name, sync_cbo_rewrite = true,
is_partition_statistics_ready = true ->
+ void mv_rewrite_success(query_sql, mv_name, sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite(),
+ is_partition_statistics_ready = true) {
logger.info("query_sql = " + query_sql + ", mv_name = " + mv_name + ",
sync_cbo_rewrite = " +sync_cbo_rewrite
+ ", is_partition_statistics_ready = " +
is_partition_statistics_ready)
if (!is_partition_statistics_ready) {
// If partition statistics is no ready, degrade to without check
cbo chosen
- return mv_rewrite_success_without_check_chosen(query_sql, mv_name,
sync_cbo_rewrite)
+ mv_rewrite_success_without_check_chosen(query_sql, mv_name,
sync_cbo_rewrite)
+ return
}
if (!sync_cbo_rewrite) {
explain {
@@ -1860,12 +1873,14 @@ class Suite implements GroovyInterceptable {
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
// is_partition_statistics_ready is the bool value which identifying if
partition row count is valid or not
// if true, check if chosen by cbo or doesn't check
- def mv_rewrite_all_success = { query_sql, mv_names, sync_cbo_rewrite =
true, is_partition_statistics_ready = true ->
+ void mv_rewrite_all_success( query_sql, mv_names, sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite(),
+ is_partition_statistics_ready = true) {
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names +
", sync_cbo_rewrite = " +sync_cbo_rewrite
+ ", is_partition_statistics_ready = " +
is_partition_statistics_ready)
if (!is_partition_statistics_ready) {
// If partition statistics is no ready, degrade to without check
cbo chosen
- return mv_rewrite_all_success_without_check_chosen(query_sql,
mv_names, sync_cbo_rewrite)
+ mv_rewrite_all_success_without_check_chosen(query_sql, mv_names,
sync_cbo_rewrite)
+ return
}
if (!sync_cbo_rewrite) {
explain {
@@ -1896,12 +1911,14 @@ class Suite implements GroovyInterceptable {
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
// is_partition_statistics_ready is the bool value which identifying if
partition row count is valid or not
// if true, check if chosen by cbo or doesn't check
- def mv_rewrite_any_success = { query_sql, mv_names, sync_cbo_rewrite =
true, is_partition_statistics_ready = true ->
+ void mv_rewrite_any_success(query_sql, mv_names, sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite(),
+ is_partition_statistics_ready = true) {
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names +
", sync_cbo_rewrite = " +sync_cbo_rewrite
+ ", is_partition_statistics_ready = " +
is_partition_statistics_ready)
if (!is_partition_statistics_ready) {
// If partition statistics is no ready, degrade to without check
cbo chosen
- return mv_rewrite_any_success_without_check_chosen(query_sql,
mv_names, sync_cbo_rewrite)
+ mv_rewrite_any_success_without_check_chosen(query_sql, mv_names,
sync_cbo_rewrite)
+ return
}
if (!sync_cbo_rewrite) {
explain {
@@ -1930,7 +1947,8 @@ class Suite implements GroovyInterceptable {
// multi mv part in rewrite process, all rewrte success without check if
chosen by cbo
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
- def mv_rewrite_all_success_without_check_chosen = { query_sql, mv_names,
sync_cbo_rewrite = true ->
+ void mv_rewrite_all_success_without_check_chosen(query_sql, mv_names,
+ sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite()){
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
if (!sync_cbo_rewrite) {
explain {
@@ -1938,7 +1956,9 @@ class Suite implements GroovyInterceptable {
check { result ->
boolean success = true;
for (String mv_name : mv_names) {
- success = success && result.contains("(${mv_name})")
+ def splitResult =
result.split("MaterializedViewRewriteFail")
+ def each_result = splitResult.length == 2 ?
splitResult[0].contains(mv_name) : false
+ success = success && (result.contains("(${mv_name})")
|| each_result)
}
Assert.assertEquals(true, success)
}
@@ -1960,7 +1980,8 @@ class Suite implements GroovyInterceptable {
// multi mv part in rewrite process, any of them rewrte success without
check if chosen by cbo or not
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
- def mv_rewrite_any_success_without_check_chosen = { query_sql, mv_names,
sync_cbo_rewrite = true ->
+ void mv_rewrite_any_success_without_check_chosen(query_sql, mv_names,
+ sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite()) {
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
if (!sync_cbo_rewrite) {
explain {
@@ -1968,7 +1989,9 @@ class Suite implements GroovyInterceptable {
check { result ->
boolean success = false;
for (String mv_name : mv_names) {
- success = success || result.contains("(${mv_name})")
+ def splitResult =
result.split("MaterializedViewRewriteFail")
+ def each_result = splitResult.length == 2 ?
splitResult[0].contains(mv_name) : false
+ success = success || (result.contains("(${mv_name})")
|| each_result)
}
Assert.assertEquals(true, success)
}
@@ -1977,7 +2000,7 @@ class Suite implements GroovyInterceptable {
}
explain {
sql(" memo plan ${query_sql}")
- check {result ->
+ check { result ->
boolean success = false
for (String mv_name : mv_names) {
success = success || result.contains("${mv_name} chose")
|| result.contains("${mv_name} not chose")
@@ -1989,12 +2012,16 @@ class Suite implements GroovyInterceptable {
// multi mv part in rewrite process, rewrte success without check if
chosen by cbo or not
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
- def mv_rewrite_success_without_check_chosen = { query_sql, mv_name,
sync_cbo_rewrite = true ->
+ void mv_rewrite_success_without_check_chosen(query_sql, mv_name,
+ sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite()) {
logger.info("query_sql = " + query_sql + ", mv_name = " + mv_name)
if (!sync_cbo_rewrite) {
explain {
sql("${query_sql}")
- contains("(${mv_name})")
+ check { result ->
+ def splitResult =
result.split("MaterializedViewRewriteFail")
+ result.contains("(${mv_name})") || (splitResult.length ==
2 ? splitResult[0].contains(mv_name) : false)
+ }
}
return
}
@@ -2008,12 +2035,12 @@ class Suite implements GroovyInterceptable {
// single mv part in rewrite process, rewrte fail
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
- def mv_rewrite_fail = { query_sql, mv_name, sync_cbo_rewrite = true ->
+ void mv_rewrite_fail(query_sql, mv_name, sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite()) {
logger.info("query_sql = " + query_sql + ", mv_name = " + mv_name)
if (!sync_cbo_rewrite) {
explain {
sql("${query_sql}")
- nonContains("(${mv_name})")
+ notContains("(${mv_name})")
}
return
}
@@ -2025,7 +2052,7 @@ class Suite implements GroovyInterceptable {
// multi mv part in rewrite process, all rewrte fail
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
- def mv_rewrite_all_fail = {query_sql, mv_names, sync_cbo_rewrite = true ->
+ void mv_rewrite_all_fail(query_sql, mv_names, sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite()) {
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
if (!sync_cbo_rewrite) {
explain {
@@ -2056,7 +2083,7 @@ class Suite implements GroovyInterceptable {
// multi mv part in rewrite process, any rewrte fail
// sync_cbo_rewrite is the bool value which control sync mv is use cbo
based mv rewrite
- def mv_rewrite_any_fail = {query_sql, mv_names, sync_cbo_rewrite = true ->
+ void mv_rewrite_any_fail (query_sql, mv_names, sync_cbo_rewrite =
enable_sync_mv_cost_based_rewrite()) {
logger.info("query_sql = " + query_sql + ", mv_names = " + mv_names)
if (!sync_cbo_rewrite) {
explain {
@@ -2095,7 +2122,7 @@ class Suite implements GroovyInterceptable {
"""
def job_name = getJobName(db, mv_name);
waitingMTMVTaskFinished(job_name)
- mv_rewrite_success(query_sql, mv_name)
+ mv_rewrite_success(query_sql, mv_name, true)
}
def async_mv_rewrite_success_without_check_chosen = { db, mv_sql,
query_sql, mv_name ->
@@ -2111,7 +2138,7 @@ class Suite implements GroovyInterceptable {
def job_name = getJobName(db, mv_name);
waitingMTMVTaskFinished(job_name)
- mv_rewrite_success_without_check_chosen(query_sql, mv_name)
+ mv_rewrite_success_without_check_chosen(query_sql, mv_name, true)
}
@@ -2128,7 +2155,7 @@ class Suite implements GroovyInterceptable {
def job_name = getJobName(db, mv_name);
waitingMTMVTaskFinished(job_name)
- mv_rewrite_fail(query_sql, mv_name)
+ mv_rewrite_fail(query_sql, mv_name, true)
}
def token = context.config.metaServiceToken
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]