cloud-fan commented on a change in pull request #24387: [SPARK-27473][SQL] 
Support filter push down for status fields in binary file data source
URL: https://github.com/apache/spark/pull/24387#discussion_r276535375
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/binaryfile/BinaryFileFormat.scala
 ##########
 @@ -142,26 +151,46 @@ class BinaryFileFormat extends FileFormat with 
DataSourceRegister {
 
 object BinaryFileFormat {
 
-  private val fileStatusSchema = StructType(
-    StructField("path", StringType, false) ::
-      StructField("modificationTime", TimestampType, false) ::
-      StructField("length", LongType, false) :: Nil)
-
   /**
    * Schema for the binary file data source.
    *
    * Schema:
+   *  - path (StringType): The path of the file.
+   *  - modificationTime (TimestampType): The modification time of the file.
+   *    In some Hadoop FileSystem implementation, this might be unavailable 
and fallback to some
+   *    default value.
+   *  - length (LongType): The length of the file in bytes.
    *  - content (BinaryType): The content of the file.
-   *  - status (StructType): The status of the file.
-   *    - path (StringType): The path of the file.
-   *    - modificationTime (TimestampType): The modification time of the file.
-   *      In some Hadoop FileSystem implementation, this might be unavailable 
and fallback to some
-   *      default value.
-   *    - length (LongType): The length of the file in bytes.
    */
   val schema = StructType(
-    StructField("content", BinaryType, true) ::
-      StructField("status", fileStatusSchema, false) :: Nil)
+    StructField("path", StringType, false) ::
+    StructField("modificationTime", TimestampType, false) ::
+    StructField("length", LongType, false) ::
+    StructField("content", BinaryType, true) :: Nil)
+
+  private[binaryfile] def createFilterFunctions(filter: Filter): 
Seq[FileStatus => Boolean] = {
+    filter match {
+      case andFilter: And =>
+        createFilterFunctions(andFilter.left) ++ 
createFilterFunctions(andFilter.right)
+      case LessThan("length", value: Long) =>
+        Seq((status: FileStatus) => status.getLen < value)
+      case LessThan("modificationTime", value: Timestamp) =>
+        Seq((status: FileStatus) => status.getModificationTime < value.getTime)
+      case LessThanOrEqual("length", value: Long) =>
 
 Review comment:
   yes, if the data type is long type.

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


With regards,
Apache Git Services

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

Reply via email to