-
Notifications
You must be signed in to change notification settings - Fork 28.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-14116][SQL] Implements buildReader() for ORC data source #11936
Closed
liancheng
wants to merge
6
commits into
apache:master
from
liancheng:spark-14116-build-reader-for-orc
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
057b6f2
WIP
liancheng b1d630b
Fixes read path of partitioned ORC table and removes duplicated code
liancheng 7d628ed
Fixes Scala style
liancheng 2cbb56d
Fixes ORC record reader instantiation
liancheng a26973e
Fixes Scala style, again
liancheng 25d894f
Addresses PR comments
liancheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ import org.apache.spark.sql.catalyst.planning.PhysicalOperation | |
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan | ||
import org.apache.spark.sql.execution.{DataSourceScan, SparkPlan} | ||
import org.apache.spark.sql.sources._ | ||
import org.apache.spark.sql.types._ | ||
|
||
/** | ||
* A strategy for planning scans over collections of files that might be partitioned or bucketed | ||
|
@@ -56,9 +55,10 @@ import org.apache.spark.sql.types._ | |
*/ | ||
private[sql] object FileSourceStrategy extends Strategy with Logging { | ||
def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match { | ||
case PhysicalOperation(projects, filters, l@LogicalRelation(files: HadoopFsRelation, _, _)) | ||
case PhysicalOperation(projects, filters, l @ LogicalRelation(files: HadoopFsRelation, _, _)) | ||
if (files.fileFormat.toString == "TestFileFormat" || | ||
files.fileFormat.isInstanceOf[parquet.DefaultSource]) && | ||
files.fileFormat.isInstanceOf[parquet.DefaultSource] || | ||
files.fileFormat.toString == "ORC") && | ||
files.sqlContext.conf.parquetFileScan => | ||
// Filters on this relation fall into four categories based on where we can use them to avoid | ||
// reading unneeded data: | ||
|
@@ -81,10 +81,10 @@ private[sql] object FileSourceStrategy extends Strategy with Logging { | |
val bucketColumns = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems this variable is never used? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea... Didn't remove it since I haven't gone through that part thoroughly. |
||
AttributeSet( | ||
files.bucketSpec | ||
.map(_.bucketColumnNames) | ||
.getOrElse(Nil) | ||
.map(l.resolveQuoted(_, files.sqlContext.conf.resolver) | ||
.getOrElse(sys.error("")))) | ||
.map(_.bucketColumnNames) | ||
.getOrElse(Nil) | ||
.map(l.resolveQuoted(_, files.sqlContext.conf.resolver) | ||
.getOrElse(sys.error("")))) | ||
|
||
// Partition keys are not available in the statistics of the files. | ||
val dataFilters = filters.filter(_.references.intersect(partitionSet).isEmpty) | ||
|
@@ -101,8 +101,8 @@ private[sql] object FileSourceStrategy extends Strategy with Logging { | |
|
||
val readDataColumns = | ||
dataColumns | ||
.filter(requiredAttributes.contains) | ||
.filterNot(partitionColumns.contains) | ||
.filter(requiredAttributes.contains) | ||
.filterNot(partitionColumns.contains) | ||
val prunedDataSchema = readDataColumns.toStructType | ||
logInfo(s"Pruned Data Schema: ${prunedDataSchema.simpleString(5)}") | ||
|
||
|
@@ -120,13 +120,12 @@ private[sql] object FileSourceStrategy extends Strategy with Logging { | |
case Some(bucketing) if files.sqlContext.conf.bucketingEnabled => | ||
logInfo(s"Planning with ${bucketing.numBuckets} buckets") | ||
val bucketed = | ||
selectedPartitions | ||
.flatMap { p => | ||
p.files.map(f => PartitionedFile(p.values, f.getPath.toUri.toString, 0, f.getLen)) | ||
}.groupBy { f => | ||
selectedPartitions.flatMap { p => | ||
p.files.map(f => PartitionedFile(p.values, f.getPath.toUri.toString, 0, f.getLen)) | ||
}.groupBy { f => | ||
BucketingUtils | ||
.getBucketId(new Path(f.filePath).getName) | ||
.getOrElse(sys.error(s"Invalid bucket file ${f.filePath}")) | ||
.getBucketId(new Path(f.filePath).getName) | ||
.getOrElse(sys.error(s"Invalid bucket file ${f.filePath}")) | ||
} | ||
|
||
(0 until bucketing.numBuckets).map { bucketId => | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this conf.