Skip to content

Commit

Permalink
Merge pull request #212 from nrkno/partition-loader-unpartioned-fix
Browse files Browse the repository at this point in the history
PartitionLoader.unpartitioned should not crash on empty table
  • Loading branch information
hamnis authored Nov 8, 2023
2 parents 0efe3d8 + c05114a commit ff79e94
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.typesafe.tools.mima.core._

// https://typelevel.org/sbt-typelevel/faq.html#what-is-a-base-version-anyway
ThisBuild / tlBaseVersion := "0.11" // your current series x.y
ThisBuild / tlBaseVersion := "0.12" // your current series x.y

ThisBuild / organization := "no.nrk.bigquery"
ThisBuild / organizationName := "NRK"
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/no/nrk/bigquery/BQTableLike.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object BQTableLike {

def loadPartition[F[_]: Concurrent](
client: BigQueryClient[F]
): F[(BQPartitionId[Unit], PartitionMetadata)] =
): F[Option[(BQPartitionId[Unit], PartitionMetadata)]] =
PartitionLoader.unpartitioned(table, client).widen
}
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/scala/no/nrk/bigquery/PartitionLoader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private[bigquery] object PartitionLoader {
case notPartitioned: BQPartitionType.NotPartitioned =>
PartitionLoader
.unpartitioned(table.withTableType[Unit](notPartitioned), client)
.map(Vector(_))
.map(_.toVector)
}

case class LongInstant(value: Instant)
Expand Down Expand Up @@ -312,7 +312,7 @@ private[bigquery] object PartitionLoader {
client: BigQueryClient[F]
)(implicit
F: Concurrent[F]
): F[(BQPartitionId.NotPartitioned, PartitionMetadata)] =
): F[Option[(BQPartitionId.NotPartitioned, PartitionMetadata)]] =
client
.synchronousQuery(
BQJobName.auto,
Expand All @@ -330,7 +330,7 @@ private[bigquery] object PartitionLoader {
(partition, metadata)
}
.compile
.lastOrError
.last

def partitionQuery(tableId: BQTableId): BQQuery[
(Option[LongInstant], Option[LongInstant], Option[Long], Option[Long])
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/no/nrk/bigquery/TableOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ object TableOps {
): F[Vector[(BQPartitionId[Unit], PartitionMetadata)]] =
table.partitionType match {
case _: BQPartitionType.NotPartitioned =>
PartitionLoader.unpartitioned(table, client).map(Vector(_)).widen
PartitionLoader.unpartitioned(table, client).map(_.toVector).widen
}
}
}

0 comments on commit ff79e94

Please sign in to comment.