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_r279115679
 
 

 ##########
 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
+      case name => throw new RuntimeException(s"Unexcepted field name: 
${name}")
+    }
+    InternalRow(values: _*)
 
 Review comment:
   What about adding a "keep invalid" option, when file read error, fill 
content column "null"?
   Now when file loaded error, the datasource loading broken.

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