wzx140 commented on code in PR #7003:
URL: https://github.com/apache/hudi/pull/7003#discussion_r1025427717


##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/hudi/HoodieInternalRowUtils.scala:
##########
@@ -72,8 +76,46 @@ object HoodieInternalRowUtils {
             } else {
               newRow.update(pos, oldValue)
             }
-          case _ =>
-            newRow.update(pos, oldValue)
+          case t if t == oldType => newRow.update(pos, oldValue)
+          // Type promotion
+          case _: ShortType =>
+            oldType match {
+              case _: ByteType => newRow.update(pos, 
oldValue.asInstanceOf[Byte].toShort)
+              case _ => throw new IllegalArgumentException(s"$oldSchema and 
$newSchema are incompatible")
+            }
+          case _: IntegerType =>
+            oldType match {
+              case _: ByteType => newRow.update(pos, 
oldValue.asInstanceOf[Byte].toInt)
+              case _: ShortType => newRow.update(pos, 
oldValue.asInstanceOf[Short].toInt)
+              case _ => throw new IllegalArgumentException(s"$oldSchema and 
$newSchema are incompatible")
+            }
+          case _: LongType =>
+            oldType match {
+              case _: ByteType => newRow.update(pos, 
oldValue.asInstanceOf[Byte].toLong)
+              case _: ShortType => newRow.update(pos, 
oldValue.asInstanceOf[Short].toLong)
+              case _: IntegerType => newRow.update(pos, 
oldValue.asInstanceOf[Int].toLong)
+              case _ => throw new IllegalArgumentException(s"$oldSchema and 
$newSchema are incompatible")
+            }
+          case _: FloatType =>
+            oldType match {
+              case _: ByteType => newRow.update(pos, 
oldValue.asInstanceOf[Byte].toFloat)
+              case _: ShortType => newRow.update(pos, 
oldValue.asInstanceOf[Short].toFloat)
+              case _: IntegerType => newRow.update(pos, 
oldValue.asInstanceOf[Int].toFloat)
+              case _: LongType => newRow.update(pos, 
oldValue.asInstanceOf[Long].toFloat)
+              case _ => throw new IllegalArgumentException(s"$oldSchema and 
$newSchema are incompatible")
+            }
+          case _: DoubleType =>
+            oldType match {
+              case _: ByteType => newRow.update(pos, 
oldValue.asInstanceOf[Byte].toDouble)
+              case _: ShortType => newRow.update(pos, 
oldValue.asInstanceOf[Short].toDouble)
+              case _: IntegerType => newRow.update(pos, 
oldValue.asInstanceOf[Int].toDouble)
+              case _: LongType => newRow.update(pos, 
oldValue.asInstanceOf[Long].toDouble)
+              case _: FloatType => newRow.update(pos, 
oldValue.asInstanceOf[Float].toDouble)
+              case _ => throw new IllegalArgumentException(s"$oldSchema and 
$newSchema are incompatible")
+            }
+          case _: BinaryType if oldType.isInstanceOf[StringType] => 
newRow.update(pos, oldValue.asInstanceOf[Array[Byte]].map(_.toChar).mkString)

Review Comment:
   fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to