From 03c025df75c56ae2d21c951c5052722a1aa76e1d Mon Sep 17 00:00:00 2001 From: Dmitry Ivankov Date: Wed, 11 Dec 2024 18:50:59 +0100 Subject: [PATCH] no unsafeRunSync inside: use flatMap+traverse --- src/main/scala/cognite/spark/v1/RawTableRelation.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/scala/cognite/spark/v1/RawTableRelation.scala b/src/main/scala/cognite/spark/v1/RawTableRelation.scala index 313207568..85caf23ad 100644 --- a/src/main/scala/cognite/spark/v1/RawTableRelation.scala +++ b/src/main/scala/cognite/spark/v1/RawTableRelation.scala @@ -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()