1
0

[HUDI-2033] ClassCastException Throw When PreCombineField Is String Type (#3099)

This commit is contained in:
pengzhiwei
2021-06-17 23:21:20 +08:00
committed by GitHub
parent 67c3124352
commit b9e28e5292
2 changed files with 66 additions and 5 deletions

View File

@@ -19,11 +19,11 @@ package org.apache.spark.sql.hudi.command.payload
import java.util.{Base64, Properties}
import java.util.concurrent.Callable
import scala.collection.JavaConverters._
import com.google.common.cache.CacheBuilder
import org.apache.avro.Schema
import org.apache.avro.generic.{GenericData, GenericRecord, IndexedRecord}
import org.apache.avro.util.Utf8
import org.apache.hudi.DataSourceWriteOptions._
import org.apache.hudi.avro.HoodieAvroUtils
import org.apache.hudi.avro.HoodieAvroUtils.bytesToAvro
@@ -290,15 +290,15 @@ object ExpressionPayload {
/**
* As the "baseEvaluator" return "UTF8String" for the string type which cannot be process by
* the Avro, The StringConvertEvaluator will convert the "UTF8String" to "String".
* the Avro, The StringConvertEvaluator will convert the "UTF8String" to "Utf8".
*/
case class StringConvertEvaluator(baseEvaluator: IExpressionEvaluator) extends IExpressionEvaluator {
/**
* Convert the UTF8String to String
* Convert the UTF8String to Utf8
*/
override def eval(record: IndexedRecord): Array[AnyRef] = {
baseEvaluator.eval(record).map{
case s: UTF8String => s.toString
baseEvaluator.eval(record).map {
case s: UTF8String => new Utf8(s.toString)
case o => o
}
}