viirya commented on a change in pull request #32194:
URL: https://github.com/apache/spark/pull/32194#discussion_r614544878



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/SchemaPruning.scala
##########
@@ -61,12 +64,16 @@ object SchemaPruning {
           sortLeftFieldsByRight(leftValueType, rightValueType),
           containsNull)
       case (leftStruct: StructType, rightStruct: StructType) =>
-        val filteredRightFieldNames = 
rightStruct.fieldNames.filter(leftStruct.fieldNames.contains)
+        val resolver = conf.resolver
+        val filteredRightFieldNames = rightStruct.fieldNames
+          .filter(name => leftStruct.fieldNames.exists(resolver(_, name)))
         val sortedLeftFields = filteredRightFieldNames.map { fieldName =>
-          val leftFieldType = leftStruct(fieldName).dataType
-          val rightFieldType = rightStruct(fieldName).dataType
+          val resolvedLeftStruct = leftStruct.filter(p => resolver(p.name, 
fieldName)).head
+          val leftFieldType = resolvedLeftStruct.dataType
+          val resolvedRightStruct = rightStruct.filter(p => resolver(p.name, 
fieldName)).head

Review comment:
       `fieldName` is from `rightStruct`. I think we can directly use `val 
rightFieldType = rightStruct(fieldName).dataType`?




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

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to