Skip to content

Commit

Permalink
[opt](mtmv) support creating views based on Hive tables with the LIMIT (
Browse files Browse the repository at this point in the history
  • Loading branch information
elon-X authored Aug 14, 2024
1 parent 51d0dfd commit 5b7278f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.apache.doris.nereids.trees.plans.logical.LogicalFileScan;
import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
import org.apache.doris.nereids.trees.plans.logical.LogicalLimit;
import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
Expand Down Expand Up @@ -509,6 +510,7 @@ public Void visitLogicalWindow(LogicalWindow<? extends Plan> window, IncrementCh
@Override
public Void visit(Plan plan, IncrementCheckerContext context) {
if (plan instanceof LogicalProject
|| plan instanceof LogicalLimit
|| plan instanceof LogicalFilter
|| plan instanceof LogicalJoin
|| plan instanceof LogicalAggregate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public void getRelatedTableInfoTestWithoutGroupTest() {
+ "JOIN "
+ "(SELECT abs(sqrt(PS_SUPPLYCOST)) as c2_abs, PS_AVAILQTY, PS_PARTKEY, PS_SUPPKEY "
+ "FROM partsupp) as ps "
+ "ON l.L_PARTKEY = ps.PS_PARTKEY and l.L_SUPPKEY = ps.PS_SUPPKEY",
+ "ON l.L_PARTKEY = ps.PS_PARTKEY and l.L_SUPPKEY = ps.PS_SUPPKEY limit 1",
nereidsPlanner -> {
Plan rewrittenPlan = nereidsPlanner.getRewrittenPlan();
RelatedTableInfo relatedTableInfo =
Expand Down Expand Up @@ -586,6 +586,24 @@ public void getRelatedTableInfoTestWithWindowButNotPartitionTest() {
});
}

@Test
public void getRelatedTableInfoTestWithLimitTest() {
PlanChecker.from(connectContext)
.checkExplain("SELECT l.L_SHIPDATE, l.L_ORDERKEY "
+ "FROM "
+ "lineitem as l limit 1",
nereidsPlanner -> {
Plan rewrittenPlan = nereidsPlanner.getRewrittenPlan();
RelatedTableInfo relatedTableInfo =
MaterializedViewUtils.getRelatedTableInfo("l_shipdate", null,
rewrittenPlan, nereidsPlanner.getCascadesContext());
checkRelatedTableInfo(relatedTableInfo,
"lineitem",
"L_SHIPDATE",
true);
});
}

@Test
public void testPartitionDateTrunc() {
PlanChecker.from(connectContext)
Expand Down

0 comments on commit 5b7278f

Please sign in to comment.