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_r261059358
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala
 ##########
 @@ -319,28 +323,26 @@ object ScalaReflection extends ScalaReflection {
         val arguments = params.zipWithIndex.map { case ((fieldName, 
fieldType), i) =>
           val Schema(dataType, nullable) = schemaFor(fieldType)
           val clsName = getClassNameFromType(fieldType)
-          val newTypePath = (s"""- field (class: "$clsName", """ +
-              s"""name: "$fieldName")""") +: walkedTypePath
+          val newPathForField = walkedTypePath.copy()
+          newPathForField.recordField(clsName, fieldName)
 
           // For tuples, we based grab the inner fields by ordinal instead of 
name.
+          val newPath = if (cls.getName startsWith "scala.Tuple") {
+            deserializerFor(
+              fieldType,
+              addToPathOrdinal(path, i, dataType, newPathForField),
+              newPathForField)
+          } else {
+            deserializerFor(
+              fieldType,
+              addToPath(path, fieldName, dataType, newPathForField),
+              newPathForField)
+          }
           deserializerForWithNullSafety(
-            path,
+            newPath,
             dataType,
             nullable = nullable,
 
 Review comment:
   I got review comment for previous PR in here as well - this is the 
reflection of replacing function to applied expression which ends up making 
`deserializerForWithNullSafety` and `expressionWithNullSafety` being same.

----------------------------------------------------------------
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