WeichenXu123 commented on a change in pull request #24473: [SPARK-27534][SQL] 
Do not load `content` column in binary data source if it is not selected
URL: https://github.com/apache/spark/pull/24473#discussion_r279114729
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/binaryfile/BinaryFileFormat.scala
 ##########
 @@ -206,6 +188,23 @@ object BinaryFileFormat {
       case _ => (_ => true)
     }
   }
+
+  private[binaryfile] def genPrunedRow(
+      path: String,
+      status: FileStatus,
+      readContent: => Array[Byte],
+      requiredFieldNames: Array[String]): InternalRow = {
+
+    val values = requiredFieldNames.map {
+      case PATH => UTF8String.fromString(path)
+      case LENGTH => status.getLen
+      case MODIFICATION_TIME => 
DateTimeUtils.fromMillis(status.getModificationTime)
+      case CONTENT => readContent
 
 Review comment:
   But I think current code is simpler.
   The previous code contains some code which is hard to read:
   ```
             val fullOutput = dataSchema.map { f =>
               AttributeReference(f.name, f.dataType, f.nullable, f.metadata)()
             }
             val requiredOutput = fullOutput.filter { a =>
               requiredSchema.fieldNames.contains(a.name)
             }
             val requiredColumns = 
GenerateUnsafeProjection.generate(requiredOutput, fullOutput)
             ...
             Iterator(requiredColumns(internalRow))
   ```

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