-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-25102][SQL] Write Spark version to ORC/Parquet file metadata #22932
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0c9ed6b
[SPARK-25102][SQL] Write Spark version to ORC/Parquet file metadata
dongjoon-hyun dfffc2e
Update test cases based on Parquet file sizes.
dongjoon-hyun 8bf632c
Use `org.apache.spark.version`.
dongjoon-hyun 396540a
Address comments
dongjoon-hyun 04457be
Refactor to functions
dongjoon-hyun 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| package org.apache.spark.sql.execution.datasources.orc | ||
|
|
||
| import java.io.File | ||
| import java.nio.charset.StandardCharsets.UTF_8 | ||
| import java.sql.Timestamp | ||
| import java.util.Locale | ||
|
|
||
|
|
@@ -30,7 +31,8 @@ import org.apache.orc.OrcProto.Stream.Kind | |
| import org.apache.orc.impl.RecordReaderImpl | ||
| import org.scalatest.BeforeAndAfterAll | ||
|
|
||
| import org.apache.spark.sql.Row | ||
| import org.apache.spark.SPARK_VERSION_SHORT | ||
| import org.apache.spark.sql.{Row, SPARK_VERSION_METADATA_KEY} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.test.SharedSQLContext | ||
| import org.apache.spark.util.Utils | ||
|
|
@@ -314,6 +316,22 @@ abstract class OrcSuite extends OrcTest with BeforeAndAfterAll { | |
| checkAnswer(spark.read.orc(path.getCanonicalPath), Row(ts)) | ||
| } | ||
| } | ||
|
|
||
|
||
| test("Write Spark version into ORC file metadata") { | ||
| withTempPath { path => | ||
| spark.range(1).repartition(1).write.orc(path.getCanonicalPath) | ||
|
|
||
| val partFiles = path.listFiles() | ||
| .filter(f => f.isFile && !f.getName.startsWith(".") && !f.getName.startsWith("_")) | ||
| assert(partFiles.length === 1) | ||
|
|
||
| val orcFilePath = new Path(partFiles.head.getAbsolutePath) | ||
| val readerOptions = OrcFile.readerOptions(new Configuration()) | ||
| val reader = OrcFile.createReader(orcFilePath, readerOptions) | ||
| val version = UTF_8.decode(reader.getMetadataValue(SPARK_VERSION_METADATA_KEY)).toString | ||
| assert(version === SPARK_VERSION_SHORT) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class OrcSourceSuite extends OrcSuite with SharedSQLContext { | ||
|
|
||
This file contains hidden or 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 hidden or 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
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.
This is basically copied from getRecordWriter
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.
Right. To avoid reflection, this was the only way.