cloud-fan commented on code in PR #39408:
URL: https://github.com/apache/spark/pull/39408#discussion_r1065844409


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileSourceStrategy.scala:
##########
@@ -258,6 +258,26 @@ object FileSourceStrategy extends Strategy with 
PredicateHelper with Logging {
       val outputAttributes = readDataColumns ++ generatedMetadataColumns ++
         partitionColumns ++ constantMetadataColumns
 
+      // Rebind metadata attribute references in filters after the metadata 
attribute struct has
+      // been flattened. Only data filters can contain metadata references. 
The rebinding will
+      // categorize the references as either 
[[FileSourceConstantMetadataAttribute]] or
+      // [[FileSourceGeneratedMetadataAttribute]].
+      def rebindFileSourceMetadataAttributesInFilters(
+          filters: Seq[Expression]): Seq[Expression] =
+        filters.map { filter =>
+          filter.transform {
+            case fieldGetter @ GetStructField(FileSourceMetadataAttribute(_), 
_, _) =>
+              val fieldName = fieldGetter.extractFieldName
+              // The row_index column has been renamed.
+              val columnName = if (fieldName == FileFormat.ROW_INDEX) {
+                FileFormat.ROW_INDEX_TEMPORARY_COLUMN_NAME
+              } else {
+                fieldName
+              }
+              metadataColumns.find(_.name == columnName).get

Review Comment:
   shall we consider case sensitivity?



-- 
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: [email protected]

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