Skip to content

Commit

Permalink
Avoid 'expected: range(0, 32768)' exception when saving mixed data to…
Browse files Browse the repository at this point in the history
… Arrow
  • Loading branch information
Kopilov authored and Kopilov committed Sep 3, 2024
1 parent ea7dbe8 commit bc8da27
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ internal class ArrowWriterImpl(
}
}

private fun convertColumnToCompatible(column: AnyCol): Pair<AnyCol, Field> {
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 ->
Expand Down Expand Up @@ -306,7 +316,7 @@ internal class ArrowWriterImpl(
cause = e,
),
)
column to column!!.toArrowField(mismatchSubscriber)
convertColumnToCompatible(column!!)
}
} catch (e: TypeConverterNotFoundException) {
if (strictType) {
Expand All @@ -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!!)
}
}

Expand Down

0 comments on commit bc8da27

Please sign in to comment.