Skip to content

Commit

Permalink
[compiler] allow relational IR in ExtractIntervals (#14013)
Browse files Browse the repository at this point in the history
Fix bug where relational IR inside the condition of a TableFilter or
MatrixFilter causes a ClassCastException. This can happen if, for
example, there's a TableAggregate inside the condition.
  • Loading branch information
patrick-schultz authored Nov 15, 2023
1 parent e9e8e17 commit 001f93a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,10 @@ class ExtractIntervalFilters(ctx: ExecuteContext, keyType: TStruct) {
}

res = if (res == null) {
val children = x.children.map(child => recur(child.asInstanceOf[IR])).toFastSeq
val children = x.children.map {
case child: IR => recur(child)
case _ => AbstractLattice.top
}.toFastSeq
val keyOrConstVal = computeKeyOrConst(x, children)
if (x.typ == TBoolean) {
if (keyOrConstVal == AbstractLattice.top)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,19 @@ class ExtractIntervalFiltersSuite extends HailSuite { outer =>
)
}

@Test def testRelationalChildren(): Unit = {
val testRows = FastSeq(
Row(0, 0, true),
Row(0, 10, true),
Row(0, 20, true),
Row(0, null, true))

val count = TableAggregate(TableRange(10, 1), ApplyAggOp(FastSeq(), FastSeq(), AggSignature(Count(), FastSeq(), FastSeq())))
print(count.typ)
val filter = gt(count, Cast(k1, TInt64))
check(filter, ref1, k1Full, testRows, filter, FastSeq(Interval(Row(), Row(), true, true)))
}

@Test def testIntegration() {
hc // force initialization
val tab1 = TableRange(10, 5)
Expand Down

0 comments on commit 001f93a

Please sign in to comment.