Skip to content

Commit d8d31e5

Browse files
committed
DRILL-7761: Drill fails with OOM for the case of large filter conditions
1 parent 3d6b67c commit d8d31e5

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/FilePushDownFilter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ protected void doOnMatch(RelOptRuleCall call, FilterPrel filter, ProjectPrel pro
136136

137137
// get a conjunctions of the filter condition. For each conjunction, if it refers to ITEM or FLATTEN expression
138138
// then we could not pushed down. Otherwise, it's qualified to be pushed down.
139-
final List<RexNode> predList = RelOptUtil.conjunctions(RexUtil.toCnf(filter.getCluster().getRexBuilder(), condition));
139+
// Limits the number of nodes that can be created out of the conversion to avoid
140+
// exponential growth of nodes count and further OOM
141+
final List<RexNode> predList = RelOptUtil.conjunctions(RexUtil.toCnf(filter.getCluster().getRexBuilder(), 100, condition));
140142

141143
final List<RexNode> qualifiedPredList = new ArrayList<>();
142144

exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetFilterPushDown.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,28 @@ public void testParquetFilterPDOptionsThreshold() throws Exception {
446446
}
447447
}
448448

449+
@Test
450+
public void testParquetFilterPDWithLargeCondition() throws Exception {
451+
test("SELECT * FROM (SELECT n.n_name AS name, n.n_nationkey AS nationkey, " +
452+
"cast(n.n_regionkey AS FLOAT) AS regionkey FROM cp.`/tpch/nation.parquet` n) " +
453+
"WHERE ((name = 'A' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
454+
"OR (name = 'B' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
455+
"OR (name = 'C' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
456+
"OR (name = 'D' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
457+
"OR (name = 'E' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
458+
"OR (name = 'F' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
459+
"OR (name = 'G' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
460+
"OR (name = 'I' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
461+
"OR (name = 'J' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
462+
"OR (name = 'K' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
463+
"OR (name = 'L' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
464+
"OR (name = 'M' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
465+
"OR (name = 'N' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
466+
"OR (name = 'O' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
467+
"OR (name = 'P' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))) " +
468+
"OR (name = 'Q' AND ((regionkey >= 0.0 AND regionkey <= 120.0 AND nationkey = 0.005))))");
469+
}
470+
449471
@Test
450472
public void testDatePredicateAgainstCorruptedDateCol() throws Exception {
451473
// Table dateTblCorrupted is created by CTAS in drill 1.8.0. Per DRILL-4203, the date column is shifted by some value.

0 commit comments

Comments
 (0)