@@ -23,7 +23,7 @@ import scala.collection.JavaConverters._
23
23
import scala .util .control .Breaks ._
24
24
import scala .util .control .NonFatal
25
25
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 }
27
27
import org .apache .spark .sql .delta .actions .{Action , AddFile , CommitInfo , RemoveFile }
28
28
import org .apache .spark .sql .delta .hooks .IcebergConverterHook
29
29
import org .apache .spark .sql .delta .metering .DeltaLogging
@@ -169,10 +169,21 @@ class IcebergConverter(spark: SparkSession)
169
169
*/
170
170
override def convertSnapshot (
171
171
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
174
186
}
175
- convertSnapshot(snapshotToConvert, None , catalogTable)
176
187
}
177
188
178
189
/**
@@ -185,22 +196,27 @@ class IcebergConverter(spark: SparkSession)
185
196
*/
186
197
override def convertSnapshot (
187
198
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)
196
211
recordDeltaEvent(
197
- snapshotToConvert .deltaLog,
198
- " delta.iceberg.conversion.skipped.emptyCatalogTable " ,
212
+ txn .deltaLog,
213
+ " delta.iceberg.conversion.error " ,
199
214
data = Map (
200
- " version" -> snapshotToConvert.version
215
+ " exception" -> ExceptionUtils .getMessage(e),
216
+ " stackTrace" -> ExceptionUtils .getStackTrace(e)
201
217
)
202
218
)
203
- None
219
+ throw e
204
220
}
205
221
}
206
222
0 commit comments