diff --git a/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt b/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt index 9c658ffabf..ff3e7ea064 100644 --- a/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt +++ b/dataframe-arrow/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/ArrowWriterImpl.kt @@ -145,6 +145,16 @@ internal class ArrowWriterImpl( } } + private fun convertColumnToCompatible(column: AnyCol): Pair { + val actualField = column.toArrowField(mismatchSubscriber) + val result = try { + convertColumnToTarget(column, actualField.type)!! + } catch (e: Exception) { + column + } + return result to actualField + } + private fun infillVector(vector: FieldVector, column: AnyCol) { when (vector) { is VarCharVector -> @@ -306,7 +316,7 @@ internal class ArrowWriterImpl( cause = e, ), ) - column to column!!.toArrowField(mismatchSubscriber) + convertColumnToCompatible(column!!) } } catch (e: TypeConverterNotFoundException) { if (strictType) { @@ -317,7 +327,7 @@ internal class ArrowWriterImpl( } else { // If strictType is not enabled, use original data with its type. Target nullable is saved at this step. mismatchSubscriber(ConvertingMismatch.TypeConversionNotFound.ConversionNotFoundIgnored(field.name, e)) - column to column!!.toArrowField(mismatchSubscriber) + convertColumnToCompatible(column!!) } }