Skip to content

Commit

Permalink
[query] Fix NullPointerException in Avro import
Browse files Browse the repository at this point in the history
We need a valid HailStateManager when generating the partitioner for
AvroPartitionReader. Instead of calculating the partitioner on the
AvroTableReader, make the partitioner computation a method that takes an
HailStateManager.

Closes #14249
  • Loading branch information
chrisvittal committed Feb 6, 2024
1 parent 7a418eb commit 6939ed4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hail/src/main/scala/is/hail/io/avro/AvroTableReader.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package is.hail.io.avro

import is.hail.backend.ExecuteContext
import is.hail.backend.{ExecuteContext, HailStateManager}
import is.hail.expr.ir._
import is.hail.expr.ir.lowering.{LowererUnsupportedOperation, TableStage, TableStageDependency}
import is.hail.rvd.RVDPartitioner
Expand All @@ -17,7 +17,7 @@ class AvroTableReader(
unsafeOptions: Option[UnsafeAvroTableReaderOptions] = None,
) extends TableReaderWithExtraUID {

private val partitioner: RVDPartitioner =
private def partitioner(stateManager: HailStateManager): RVDPartitioner =
unsafeOptions.map { case UnsafeAvroTableReaderOptions(key, intervals, _) =>
require(
intervals.length == paths.length,
Expand All @@ -27,12 +27,12 @@ class AvroTableReader(
)} and ${intervals.length} ${plural(intervals.length, "interval")}",
)
RVDPartitioner.generate(
null,
stateManager,
partitionReader.fullRowType.typeAfterSelectNames(key),
intervals,
)
}.getOrElse {
RVDPartitioner.unkeyed(null, paths.length)
RVDPartitioner.unkeyed(stateManager, paths.length)
}

def pathsUsed: Seq[String] = paths
Expand Down Expand Up @@ -75,7 +75,7 @@ class AvroTableReader(
}
TableStage(
globals,
partitioner,
partitioner(ctx.stateManager),
TableStageDependency.none,
contexts,
ctx => ReadPartition(ctx, requestedType.rowType, partitionReader),
Expand Down

0 comments on commit 6939ed4

Please sign in to comment.