-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-25102][SQL][2.4] Write Spark version to ORC/Parquet file metadata #28142
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,4 +73,29 @@ class VersionUtilsSuite extends SparkFunSuite { | |
} | ||
} | ||
} | ||
|
||
test("Return short version number") { | ||
assert(shortVersion("3.0.0") === "3.0.0") | ||
assert(shortVersion("3.0.0-SNAPSHOT") === "3.0.0") | ||
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. I didn't change the version |
||
withClue("shortVersion parsing should fail for missing maintenance version number") { | ||
intercept[IllegalArgumentException] { | ||
shortVersion("3.0") | ||
} | ||
} | ||
withClue("shortVersion parsing should fail for invalid major version number") { | ||
intercept[IllegalArgumentException] { | ||
shortVersion("x.0.0") | ||
} | ||
} | ||
withClue("shortVersion parsing should fail for invalid minor version number") { | ||
intercept[IllegalArgumentException] { | ||
shortVersion("3.x.0") | ||
} | ||
} | ||
withClue("shortVersion parsing should fail for invalid maintenance version number") { | ||
intercept[IllegalArgumentException] { | ||
shortVersion("3.0.x") | ||
} | ||
} | ||
} | ||
} |
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 | ||
|
||
|
@@ -29,7 +30,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 | ||
|
@@ -243,6 +245,22 @@ abstract class OrcSuite extends OrcTest with BeforeAndAfterAll { | |
checkAnswer(spark.read.orc(path.getCanonicalPath), Row(ts)) | ||
} | ||
} | ||
|
||
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. Please note that the following test case is executed twice; OrcSourceSuite and HiveOrcSourceSuite. |
||
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 { | ||
|
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.
I didn't change this example in order to minimize the diff between
branch-2.4
andmaster
.