Skip to content

Commit

Permalink
no unsafeRunSync inside: use flatMap+traverse
Browse files Browse the repository at this point in the history
  • Loading branch information
dmivankov committed Dec 11, 2024
1 parent e570aa9 commit 03c025d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/cognite/spark/v1/RawTableRelation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ class RawTableRelation(
config.maxOutstandingRawInsertRequests match {
case Some(maxOutstandingRawInsertRequests) =>
Backpressure[IO](Backpressure.Strategy.Lossless, maxOutstandingRawInsertRequests)
.map { backpressure =>
rows.grouped(batchSize).toVector.foreach { batch: Seq[Row] =>
backpressure.metered(postRows(columnNames, batch)).unsafeRunSync()
.flatMap { backpressure =>
rows.grouped(batchSize).toVector.traverse_ { batch: Seq[Row] =>
backpressure.metered(postRows(columnNames, batch))
}
}
.unsafeRunSync()
Expand Down

0 comments on commit 03c025d

Please sign in to comment.