-
Notifications
You must be signed in to change notification settings - Fork 253
Closed
Description
What is the problem the feature request solves?
Spark supports casting a struct to a different struct type. We should add support in Comet.
private[this] def castStruct(from: StructType, to: StructType): Any => Any = {
val castFuncs: Array[(Any) => Any] = from.fields.zip(to.fields).map {
case (fromField, toField) => cast(fromField.dataType, toField.dataType)
}
// TODO: Could be faster?
buildCast[InternalRow](_, row => {
val newRow = new GenericInternalRow(from.fields.length)
var i = 0
while (i < row.numFields) {
newRow.update(i,
if (row.isNullAt(i)) null else castFuncs(i)(row.get(i, from.apply(i).dataType)))
i += 1
}
newRow
})
}Describe the potential solution
No response
Additional context
No response
Metadata
Metadata
Labels
enhancementNew feature or requestNew feature or request