HeartSaVioR commented on a change in pull request #23908:  [SPARK-27001][SQL] 
Refactor "serializerFor" method between ScalaReflection and JavaTypeInference
URL: https://github.com/apache/spark/pull/23908#discussion_r261501361
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/JavaTypeInference.scala
 ##########
 @@ -274,38 +274,40 @@ object JavaTypeInference {
 
       case c if listType.isAssignableFrom(typeToken) =>
         val et = elementType(typeToken)
-        val newTypePath = s"""- array element class: 
"${et.getType.getTypeName}"""" +:
-          walkedTypePath
+        walkedTypePath.recordArray(et.getType.getTypeName)
         val (dataType, elementNullable) = inferDataType(et)
         val mapFunction: Expression => Expression = element => {
           // upcast the array element to the data type the encoder expected.
           deserializerForWithNullSafetyAndUpcast(
             element,
             dataType,
             nullable = elementNullable,
-            newTypePath,
+            walkedTypePath,
             (casted, typePath) => deserializerFor(et, casted, typePath))
         }
 
         UnresolvedMapObjects(mapFunction, path, customCollectionCls = Some(c))
 
       case _ if mapType.isAssignableFrom(typeToken) =>
         val (keyType, valueType) = mapKeyValueType(typeToken)
-        val newTypePath = (s"""- map key class: 
"${keyType.getType.getTypeName}"""" +
-          s""", value class: "${valueType.getType.getTypeName}"""") +: 
walkedTypePath
+        walkedTypePath.recordMap(keyType.getType.getTypeName,
+          valueType.getType.getTypeName)
+
+        val newTypePathForKey = walkedTypePath.copy()
+        val newTypePathForValue = walkedTypePath.copy()
 
 Review comment:
   Yeah, same understanding. No problem! I'll revert back to let WalkedTypePath 
be immutable one.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to