@@ -23,7 +23,7 @@ import scala.collection.JavaConverters._
2323import scala .util .control .Breaks ._
2424import scala .util .control .NonFatal
2525
26- import org .apache .spark .sql .delta .{DeltaFileNotFoundException , DeltaFileProviderUtils , OptimisticTransactionImpl , Snapshot , UniversalFormat , UniversalFormatConverter }
26+ import org .apache .spark .sql .delta .{DeltaErrors , DeltaFileNotFoundException , DeltaFileProviderUtils , OptimisticTransactionImpl , Snapshot , UniversalFormat , UniversalFormatConverter }
2727import org .apache .spark .sql .delta .actions .{Action , AddFile , CommitInfo , RemoveFile }
2828import org .apache .spark .sql .delta .hooks .IcebergConverterHook
2929import org .apache .spark .sql .delta .metering .DeltaLogging
@@ -169,10 +169,21 @@ class IcebergConverter(spark: SparkSession)
169169 */
170170 override def convertSnapshot (
171171 snapshotToConvert : Snapshot , catalogTable : CatalogTable ): Option [(Long , Long )] = {
172- if (! UniversalFormat .icebergEnabled(snapshotToConvert.metadata)) {
173- return None
172+ try {
173+ convertSnapshot(snapshotToConvert, None , catalogTable)
174+ } catch {
175+ case NonFatal (e) =>
176+ logError(s " Error when converting to Iceberg metadata " , e)
177+ recordDeltaEvent(
178+ snapshotToConvert.deltaLog,
179+ " delta.iceberg.conversion.error" ,
180+ data = Map (
181+ " exception" -> ExceptionUtils .getMessage(e),
182+ " stackTrace" -> ExceptionUtils .getStackTrace(e)
183+ )
184+ )
185+ throw e
174186 }
175- convertSnapshot(snapshotToConvert, None , catalogTable)
176187 }
177188
178189 /**
@@ -185,22 +196,27 @@ class IcebergConverter(spark: SparkSession)
185196 */
186197 override def convertSnapshot (
187198 snapshotToConvert : Snapshot , txn : OptimisticTransactionImpl ): Option [(Long , Long )] = {
188- if (! UniversalFormat .icebergEnabled(snapshotToConvert.metadata)) {
189- return None
190- }
191- txn.catalogTable match {
192- case Some (table) => convertSnapshot(snapshotToConvert, Some (txn), table)
193- case _ =>
194- logWarning(s " CatalogTable for table ${snapshotToConvert.deltaLog.tableId} " +
195- s " is empty in txn. Skip iceberg conversion. " )
199+ try {
200+ txn.catalogTable match {
201+ case Some (table) => convertSnapshot(snapshotToConvert, Some (txn), table)
202+ case _ =>
203+ val msg = s " CatalogTable for table ${snapshotToConvert.deltaLog.tableId} " +
204+ s " is empty in txn. Skip iceberg conversion. "
205+ throw DeltaErrors .universalFormatConversionFailedException(
206+ snapshotToConvert.version, " iceberg" , msg)
207+ }
208+ } catch {
209+ case NonFatal (e) =>
210+ logError(s " Error when converting to Iceberg metadata " , e)
196211 recordDeltaEvent(
197- snapshotToConvert .deltaLog,
198- " delta.iceberg.conversion.skipped.emptyCatalogTable " ,
212+ txn .deltaLog,
213+ " delta.iceberg.conversion.error " ,
199214 data = Map (
200- " version" -> snapshotToConvert.version
215+ " exception" -> ExceptionUtils .getMessage(e),
216+ " stackTrace" -> ExceptionUtils .getStackTrace(e)
201217 )
202218 )
203- None
219+ throw e
204220 }
205221 }
206222
0 commit comments