branch-2.1: [fix](mtmv) Fix partition track column fail when 'select *' used in related partition side #43531 (#43941)

Cherry-picked from #43531

Co-authored-by: seawinde <wusi@selectdb.com>
This commit is contained in:
github-actions[bot]
2024-11-19 20:27:13 +08:00
committed by GitHub
parent 3136fa48a6
commit 1913e4e78d
2 changed files with 22 additions and 2 deletions

View File

@ -374,11 +374,11 @@ public class MaterializedViewUtils {
} else if ((joinType.isLeftJoin()
|| joinType.isLefSemiJoin()
|| joinType.isLeftAntiJoin()) && useLeft) {
return visit(join.left(), context);
return join.left().accept(this, context);
} else if ((joinType.isRightJoin()
|| joinType.isRightAntiJoin()
|| joinType.isRightSemiJoin()) && !useLeft) {
return visit(join.right(), context);
return join.right().accept(this, context);
}
context.addFailReason(String.format("partition column is in un supported join null generate side, "
+ "current join type is %s", joinType));

View File

@ -421,6 +421,26 @@ public class MaterializedViewUtilsTest extends TestWithFeService {
});
}
// if select * used in partition table side, should get related table
@Test
public void getRelatedTableInfoLeftJoinSelectStarTest() {
PlanChecker.from(connectContext)
.checkExplain(" select l1.*, O_CUSTKEY \n"
+ " from lineitem_list_partition l1\n"
+ " left outer join orders_list_partition\n"
+ " on l1.l_shipdate = o_orderdate\n",
nereidsPlanner -> {
Plan rewrittenPlan = nereidsPlanner.getRewrittenPlan();
RelatedTableInfo relatedTableInfo =
MaterializedViewUtils.getRelatedTableInfo("l_orderkey", null,
rewrittenPlan, nereidsPlanner.getCascadesContext());
checkRelatedTableInfo(relatedTableInfo,
"lineitem_list_partition",
"l_orderkey",
true);
});
}
@Test
public void getRelatedTableInfoSelfJoinTest() {
PlanChecker.from(connectContext)