Skip to content

Commit fd3cdf5

Browse files
committed
fix:using simplifyOptimizerRules wasn't RemoveEmptyUnionBranches
1 parent 424e8b5 commit fd3cdf5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

core/trino-main/src/main/java/io/trino/sql/planner/PlanOptimizers.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ public PlanOptimizers(
963963
.add(new PushFilterIntoValues(plannerContext))
964964
.add(new ReplaceJoinOverConstantWithProject())
965965
.add(new RemoveRedundantPredicateAboveTableScan(plannerContext))
966+
.add(new RemoveEmptyUnionBranches())
966967
.build()));
967968
// Remove unsupported dynamic filters introduced by PredicatePushdown. Also, cleanup dynamic filters removed by
968969
// PushPredicateIntoTableScan and RemoveRedundantPredicateAboveTableScan due to those rules replacing table scans with empty ValuesNode

core/trino-main/src/test/java/io/trino/sql/planner/TestLogicalPlanner.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,6 +1332,32 @@ public void testRemovesTrivialFilters()
13321332
values("nationkey", "name", "regionkey", "comment")));
13331333
}
13341334

1335+
@Test
1336+
public void testRemoveTrivialFiltersWithPartitioningHandle()
1337+
{
1338+
assertThat(countOfMatchingNodes(
1339+
plan("""
1340+
SELECT *
1341+
FROM (
1342+
SELECT n.name AS "col1",
1343+
n.nationkey AS "col2",
1344+
CAST(null AS varchar) AS "col3"
1345+
FROM nation n
1346+
WHERE n.nationkey <= 3
1347+
UNION ALL
1348+
SELECT r.name AS "col1",
1349+
CAST(r.regionkey AS bigint) AS "col2",
1350+
r.comment AS "col3"
1351+
FROM region r
1352+
) subquery
1353+
WHERE "col3" IN (
1354+
SELECT r.comment
1355+
FROM region r
1356+
)
1357+
"""),
1358+
ValuesNode.class::isInstance)).isEqualTo(0);
1359+
}
1360+
13351361
@Test
13361362
public void testRemovesNullFilter()
13371363
{

0 commit comments

Comments
 (0)