Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,12 @@ public Statistics computeOlapScan(OlapScan olapScan) {
optStats.isPresent(), tableRowCount, olapTable.getQualifiedName());
if (optStats.isPresent()) {
double selectedPartitionsRowCount = getSelectedPartitionRowCount(olapScan, tableRowCount);
if (isRegisteredRowCount(olapScan)) {
// If a row count is injected for the materialized view, use it to fix the issue where
// the materialized view cannot be selected by cbo stable due to selectedPartitionsRowCount being 0,
// which is caused by delayed statistics reporting.
selectedPartitionsRowCount = tableRowCount;
}
LOG.info("computeOlapScan optStats is {}, selectedPartitionsRowCount is {}", optStats.get(),
selectedPartitionsRowCount);
// if estimated mv rowCount is more than actual row count, fall back to base table stats
Expand Down
15 changes: 0 additions & 15 deletions fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.doris.nereids.metrics.EventSwitchParser;
import org.apache.doris.nereids.parser.Dialect;
import org.apache.doris.nereids.rules.RuleType;
import org.apache.doris.nereids.rules.exploration.mv.PreMaterializedViewRewriter.PreRewriteStrategy;
import org.apache.doris.nereids.rules.expression.ExpressionRuleType;
import org.apache.doris.planner.GroupCommitBlockSink;
import org.apache.doris.qe.VariableMgr.VarAttr;
Expand Down Expand Up @@ -3289,20 +3288,6 @@ public void initFuzzyModeVariables() {
this.enableReserveMemory = randomInt % 5 != 0;
}

// random pre materialized view rewrite strategy
randomInt = random.nextInt(3);
switch (randomInt % 3) {
case 0:
this.preMaterializedViewRewriteStrategy = PreRewriteStrategy.NOT_IN_RBO.name();
break;
case 1:
this.preMaterializedViewRewriteStrategy = PreRewriteStrategy.TRY_IN_RBO.name();
break;
case 2:
default:
this.preMaterializedViewRewriteStrategy = PreRewriteStrategy.FORCE_IN_RBO.name();
break;
}
setFuzzyForCatalog(random);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ suite ("multiple_no_where") {
qt_select_star "select * from lineorder_flat order by 1,2, P_MFGR;"

sql """analyze table lineorder_flat with sync;"""
sql """alter table lineorder_flat modify column C_CITY set stats ('row_count'='7');"""
sql """alter table lineorder_flat modify column a3 set stats ('row_count'='1');"""
sql """set enable_stats=false;"""

mv_rewrite_success("""SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ suite ("multiple_ssb") {

sql """analyze table lineorder_flat with sync;"""
sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""
sql """alter table lineorder_flat modify column a1 set stats ('row_count'='1');"""
sql """alter table lineorder_flat modify column a4 set stats ('row_count'='1');"""
sql """alter table lineorder_flat modify column a6 set stats ('row_count'='1');"""
sql """alter table lineorder_flat modify column x2 set stats ('row_count'='1');"""
sql """set enable_stats=false;"""

mv_rewrite_success("""SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ suite ("multiple_ssb_between") {
sql """set enable_stats=true;"""

sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""

sql """alter table lineorder_flat modify column a1 set stats ('row_count'='1');"""
sql """alter table lineorder_flat modify column a4 set stats ('row_count'='1');"""
sql """alter table lineorder_flat modify column a6 set stats ('row_count'='1');"""
sql """alter table lineorder_flat modify column x2 set stats ('row_count'='1');"""

mv_rewrite_success("""SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
FROM lineorder_flat
WHERE
Expand Down
1 change: 1 addition & 0 deletions regression-test/suites/mv_p0/ssb/q_1_1/q_1_1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ suite ("mv_ssb_q_1_1") {

sql "analyze table lineorder_flat with sync;"
sql """alter table lineorder_flat modify column C_CITY set stats ('row_count'='6');"""
sql """alter table lineorder_flat modify column a1 set stats ('row_count'='1');"""
mv_rewrite_success("""SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
FROM lineorder_flat
WHERE
Expand Down
1 change: 1 addition & 0 deletions regression-test/suites/mv_p0/ssb/q_2_1/q_2_1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ suite ("mv_ssb_q_2_1") {
qt_select_star "select * from lineorder_flat order by 1,2,P_MFGR;"

sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='2');"""
sql """alter table lineorder_flat modify column a2 set stats ('row_count'='1');"""

mv_rewrite_success("""SELECT
SUM(LO_REVENUE), (LO_ORDERDATE DIV 10000) AS YEAR,
Expand Down
1 change: 1 addition & 0 deletions regression-test/suites/mv_p0/ssb/q_3_1/q_3_1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ suite ("mv_ssb_q_3_1") {
sql """analyze table lineorder_flat with sync;"""

sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='2');"""
sql """alter table lineorder_flat modify column a1 set stats ('row_count'='1');"""

mv_rewrite_success("""SELECT
C_NATION,
Expand Down
1 change: 1 addition & 0 deletions regression-test/suites/mv_p0/ssb/q_4_1/q_4_1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ suite ("mv_ssb_q_4_1") {
sql """analyze table lineorder_flat with sync;"""

sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='2');"""
sql """alter table lineorder_flat modify column a2 set stats ('row_count'='1');"""

mv_rewrite_success("""SELECT (LO_ORDERDATE DIV 10000) AS YEAR,
C_NATION,
Expand Down
1 change: 1 addition & 0 deletions regression-test/suites/mv_p0/ssb/q_4_1_r1/q_4_1_r1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ suite ("q_4_1_r1") {

sql """analyze table lineorder_flat with sync;"""
sql """alter table lineorder_flat modify column LO_ORDERDATE set stats ('row_count'='8');"""
sql """alter table lineorder_flat modify column a1 set stats ('row_count'='1');"""
sql """set enable_stats=false;"""

mv_rewrite_success("""SELECT (LO_ORDERDATE DIV 10000) AS YEAR,
Expand Down
Loading