Skip to content

Commit

Permalink
[query] avoid code explosion for trivial upcasts (#14232)
Browse files Browse the repository at this point in the history
  • Loading branch information
danking authored Feb 1, 2024
1 parent 171b39d commit 7f12473
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions hail/src/main/scala/is/hail/expr/ir/PruneDeadFields.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2853,12 +2853,16 @@ object PruneDeadFields {
ir
else {
val result = ir.typ match {
case _: TStruct =>
bindIR(ir) { ref =>
val ms = MakeStruct(rType.asInstanceOf[TStruct].fields.map { f =>
f.name -> upcast(ctx, GetField(ref, f.name), f.typ)
})
If(IsNA(ref), NA(ms.typ), ms)
case tstruct: TStruct =>
if (rType.asInstanceOf[TStruct].fields.forall(f => tstruct.field(f.name).typ == f.typ)) {
SelectFields(ir, rType.asInstanceOf[TStruct].fields.map(f => f.name))
} else {
bindIR(ir) { ref =>
val ms = MakeStruct(rType.asInstanceOf[TStruct].fields.map { f =>
f.name -> upcast(ctx, GetField(ref, f.name), f.typ)
})
If(IsNA(ref), NA(ms.typ), ms)
}
}
case ts: TStream =>
val ra = rType.asInstanceOf[TStream]
Expand Down

0 comments on commit 7f12473

Please sign in to comment.