HyukjinKwon 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_r279178255
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/binaryfile/BinaryFileFormat.scala
##########
@@ -101,43 +98,27 @@ class BinaryFileFormat extends FileFormat with
DataSourceRegister {
val filterFuncs = filters.map(filter => createFilterFunction(filter))
file: PartitionedFile => {
- val path = file.filePath
- val fsPath = new Path(path)
-
+ val path = new Path(file.filePath)
// TODO: Improve performance here: each file will recompile the glob
pattern here.
- if (pathGlobPattern.forall(new GlobFilter(_).accept(fsPath))) {
- val fs = fsPath.getFileSystem(broadcastedHadoopConf.value.value)
- val fileStatus = fs.getFileStatus(fsPath)
- val length = fileStatus.getLen
- val modificationTime = fileStatus.getModificationTime
-
- if (filterFuncs.forall(_.apply(fileStatus))) {
- val stream = fs.open(fsPath)
- val content = try {
- ByteStreams.toByteArray(stream)
- } finally {
- Closeables.close(stream, true)
- }
-
- val fullOutput = dataSchema.map { f =>
- AttributeReference(f.name, f.dataType, f.nullable, f.metadata)()
- }
- val requiredOutput = fullOutput.filter { a =>
- requiredSchema.fieldNames.contains(a.name)
+ if (pathGlobPattern.forall(new GlobFilter(_).accept(path))) {
Review comment:
Yes, this suggestion does not touch both because they are lazy
----------------------------------------------------------------
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]