This is an automated email from the ASF dual-hosted git repository.
gavinchou 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 36ce7a7dbe8 [fix](mtmv) Fix partition trace wrong when partition name
is same from both side of join (#40485) (#40810)
36ce7a7dbe8 is described below
commit 36ce7a7dbe8bc7fc2e64e5cf05fa7283f9ed64f6
Author: seawinde <[email protected]>
AuthorDate: Sat Sep 14 14:54:09 2024 +0800
[fix](mtmv) Fix partition trace wrong when partition name is same from both
side of join (#40485) (#40810)
pr: https://github.com/apache/doris/pull/40485
commitId: 18a374f6
---
.../rules/exploration/mv/MaterializedViewUtils.java | 18 ++++++++++++++----
.../trees/plans/commands/info/CreateMTMVInfo.java | 4 +++-
.../nereids/trees/plans/logical/LogicalOlapScan.java | 3 ---
.../exploration/mv/MaterializedViewUtilsTest.java | 20 ++++++++++++++++++++
...nable_date_non_deterministic_function_mtmv.groovy | 6 +++---
5 files changed, 40 insertions(+), 11 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
index 254297842b5..235a84e596b 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtils.java
@@ -429,6 +429,20 @@ public class MaterializedViewUtils {
+ "but now is %s",
relation.getClass().getSimpleName()));
return null;
}
+ SlotReference contextPartitionColumn =
getContextPartitionColumn(context);
+ if (contextPartitionColumn == null) {
+ context.addFailReason(String.format("mv partition column is
not from table when relation check, "
+ + "mv partition column is %s",
context.getMvPartitionColumn()));
+ return null;
+ }
+ // Check the table which mv partition column belonged to is same
as the current check relation or not
+ if (!((LogicalCatalogRelation)
relation).getTable().getFullQualifiers().equals(
+
contextPartitionColumn.getTable().map(TableIf::getFullQualifiers).orElse(ImmutableList.of())))
{
+ context.addFailReason(String.format("mv partition column name
is not belonged to current check , "
+ + "table, current table is %s",
+ ((LogicalCatalogRelation)
relation).getTable().getFullQualifiers()));
+ return null;
+ }
LogicalCatalogRelation logicalCatalogRelation =
(LogicalCatalogRelation) relation;
TableIf table = logicalCatalogRelation.getTable();
// if self join, self join can not partition track now, remove the
partition column correspondingly
@@ -457,10 +471,6 @@ public class MaterializedViewUtils {
return null;
}
Set<Column> partitionColumnSet = new
HashSet<>(relatedTable.getPartitionColumns());
- SlotReference contextPartitionColumn =
getContextPartitionColumn(context);
- if (contextPartitionColumn == null) {
- return null;
- }
Column mvReferenceColumn =
contextPartitionColumn.getColumn().get();
Expr definExpr = mvReferenceColumn.getDefineExpr();
if (definExpr instanceof SlotRef) {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
index f35d3c36285..0ce6aea8565 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
@@ -373,7 +373,9 @@ public class CreateMTMVInfo {
List<Expression> functionCollectResult =
MaterializedViewUtils.extractNondeterministicFunction(plan);
if (!CollectionUtils.isEmpty(functionCollectResult)) {
throw new AnalysisException(String.format(
- "can not contain invalid expression, the expression is %s",
+ "can not contain nonDeterministic expression, the
expression is %s. "
+ + "Should add 'enable_nondeterministic_function'
= 'true' property "
+ + "when create materialized view if you know the
property real meaning entirely",
functionCollectResult.stream().map(Expression::toString).collect(Collectors.joining(","))));
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
index ef3d4c43d82..15e06816c1a 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
@@ -538,9 +538,6 @@ public class LogicalOlapScan extends LogicalCatalogRelation
implements OlapScan
@Override
public void computeEqualSet(DataTrait.Builder builder) {
- if (getTable() instanceof MTMV && getTable().getName().equals("mv1")) {
- System.out.println();
- }
if (getTable() instanceof MTMV) {
MTMV mtmv = (MTMV) getTable();
MTMVCache cache = mtmv.getCache();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtilsTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtilsTest.java
index b44e1cc3ec6..ccc759dff3d 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtilsTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/mv/MaterializedViewUtilsTest.java
@@ -251,6 +251,26 @@ public class MaterializedViewUtilsTest extends
TestWithFeService {
connectContext.getSessionVariable().setDisableNereidsRules("OLAP_SCAN_PARTITION_PRUNE,PRUNE_EMPTY_PARTITION");
}
+ // Test when join both side are all partition table and partition column
name is same
+ @Test
+ public void joinPartitionNameSameTest() {
+ PlanChecker.from(connectContext)
+ .checkExplain("select t1.upgrade_day, t2.batch_no, count(*) "
+ + "from test2 t2 join test1 t1 on "
+ + "t1.upgrade_day = t2.upgrade_day "
+ + "group by t1.upgrade_day, t2.batch_no;",
+ nereidsPlanner -> {
+ Plan rewrittenPlan =
nereidsPlanner.getRewrittenPlan();
+ RelatedTableInfo relatedTableInfo =
+
MaterializedViewUtils.getRelatedTableInfo("upgrade_day", null,
+ rewrittenPlan,
nereidsPlanner.getCascadesContext());
+ checkRelatedTableInfo(relatedTableInfo,
+ "test1",
+ "upgrade_day",
+ true);
+ });
+ }
+
@Test
public void getRelatedTableInfoWhenAutoPartitionTest() {
PlanChecker.from(connectContext)
diff --git
a/regression-test/suites/mtmv_p0/test_enable_date_non_deterministic_function_mtmv.groovy
b/regression-test/suites/mtmv_p0/test_enable_date_non_deterministic_function_mtmv.groovy
index c085779e707..a8705c6ba9e 100644
---
a/regression-test/suites/mtmv_p0/test_enable_date_non_deterministic_function_mtmv.groovy
+++
b/regression-test/suites/mtmv_p0/test_enable_date_non_deterministic_function_mtmv.groovy
@@ -57,7 +57,7 @@
suite("test_enable_date_non_deterministic_function_mtmv","mtmv") {
Assert.fail();
} catch (Exception e) {
logger.info(e.getMessage())
- assertTrue(e.getMessage().contains("can not contain invalid
expression"));
+ assertTrue(e.getMessage().contains("can not contain nonDeterministic
expression"));
}
sql """drop materialized view if exists ${mvName};"""
@@ -75,7 +75,7 @@
suite("test_enable_date_non_deterministic_function_mtmv","mtmv") {
Assert.fail();
} catch (Exception e) {
logger.info(e.getMessage())
- assertTrue(e.getMessage().contains("can not contain invalid
expression"));
+ assertTrue(e.getMessage().contains("can not contain nonDeterministic
expression"));
}
sql """drop materialized view if exists ${mvName};"""
@@ -128,7 +128,7 @@
suite("test_enable_date_non_deterministic_function_mtmv","mtmv") {
Assert.fail();
} catch (Exception e) {
logger.info(e.getMessage())
- assertTrue(e.getMessage().contains("can not contain invalid
expression"));
+ assertTrue(e.getMessage().contains("can not contain nonDeterministic
expression"));
}
sql """drop table if exists `${tableName}`"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]