cloud-fan commented on a change in pull request #35055:
URL: https://github.com/apache/spark/pull/35055#discussion_r776557948



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/PartitioningAwareFileIndex.scala
##########
@@ -71,8 +73,34 @@ abstract class PartitioningAwareFileIndex(
     def isNonEmptyFile(f: FileStatus): Boolean = {
       isDataPath(f.getPath) && f.getLen > 0
     }
+
+    // retrieve the file metadata filters and reduce to a final filter 
expression
+    val fileMetadataFilterOpt = dataFilters.filter(_.references.forall {
+      case MetadataAttribute(_) => true
+      case _ => false
+    }).reduceOption(expressions.And)
+
+    // will create internal rows for each file, position 0: Metadata Struct
+    val boundedFilterOpt = fileMetadataFilterOpt.map { fileMetadataFilter =>
+      Predicate.createInterpreted(fileMetadataFilter.transform {
+        case _: AttributeReference => BoundReference(0, METADATA_STRUCT, 
nullable = true)
+      })
+    }
+
+    def matchFileMetadataPredicate(f: FileStatus): Boolean = {
+      // use option.forall, so if there is no filter, return true
+      boundedFilterOpt.forall(_.eval(
+        InternalRow.fromSeq(Seq(InternalRow.fromSeq(Seq(

Review comment:
       Can we have a util method to create InternalRow from `Path`, `length: 
Long` and `modificationTime: Long`? To share code with `FileScanRDD`




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