Skip to content

Commit

Permalink
[query] Fix NullPointerException in Avro import (#14258)
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 authored Feb 9, 2024
1 parent 71cd318 commit faae93c
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 faae93c

Please sign in to comment.