You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "danny0405 (via GitHub)" <gi...@apache.org> on 2023/04/13 06:35:17 UTC

[GitHub] [hudi] danny0405 commented on a diff in pull request #8432: Fix NPE when upsert merger and null map or array

danny0405 commented on code in PR #8432:
URL: https://github.com/apache/hudi/pull/8432#discussion_r1165066350


##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/spark/sql/HoodieInternalRowUtils.scala:
##########
@@ -224,29 +224,32 @@ object HoodieInternalRowUtils {
         fieldNameStack.pop()
 
         (fieldUpdater, ordinal, value) => {
-          val prevArrayData = value.asInstanceOf[ArrayData]
-          val prevArray = prevArrayData.toObjectArray(prevElementType)
-
-          val newArrayData = createArrayData(newElementType, prevArrayData.numElements())
-          val elementUpdater = new ArrayDataUpdater(newArrayData)
-
-          var i = 0
-          while (i < prevArray.length) {
-            val element = prevArray(i)
-            if (element == null) {
-              if (!containsNull) {
-                throw new HoodieException(
-                  s"Array value at path '${fieldNameStack.asScala.mkString(".")}' is not allowed to be null")
+          if (value == null) {
+            fieldUpdater.setNullAt(ordinal)
+          } else {
+            val prevArrayData = value.asInstanceOf[ArrayData]
+            val prevArray = prevArrayData.toObjectArray(prevElementType)
+

Review Comment:
   Thanks for the contribution, can we add some test cases?



-- 
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-unsubscribe@hudi.apache.org

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