-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-11044][SQL] Parquet writer version fixed as version1 #9060
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
Changes from 6 commits
5e72fbc
2eee7e3
2d1d343
65f2647
7e80ad6
78449ec
cea5034
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 |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ package org.apache.spark.sql.execution.datasources.parquet | |
|
|
||
| import java.util.Collections | ||
|
|
||
| import org.apache.parquet.column.{Encoding, ParquetProperties} | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
| import scala.reflect.ClassTag | ||
| import scala.reflect.runtime.universe.TypeTag | ||
|
|
@@ -513,6 +515,41 @@ class ParquetIOSuite extends QueryTest with ParquetTest with SharedSQLContext { | |
| } | ||
| } | ||
|
|
||
| test("SPARK-11044 Parquet writer version fixed as version1 ") { | ||
|
|
||
| // For dictionary encoding, Parquet changes the encoding types according to its writer version | ||
| // So, this test checks the encoding types in order to ensure that the file is written with | ||
| // writer version2. | ||
| withTempPath { dir => | ||
| val clonedConf = new Configuration(hadoopConfiguration) | ||
| try { | ||
|
|
||
|
Contributor
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. Nit: Remove this empty line. |
||
| // Write a Parquet file with writer version 2 | ||
| hadoopConfiguration.set(ParquetOutputFormat.WRITER_VERSION, | ||
| ParquetProperties.WriterVersion.PARQUET_2_0.toString) | ||
|
|
||
| // By default, dictionary encoding is enabled from Parquet 1.2.0 but | ||
| // it is enabled just in case. | ||
| hadoopConfiguration.setBoolean(ParquetOutputFormat.ENABLE_DICTIONARY, true) | ||
| val path = s"${dir.getCanonicalPath}/part-r-0.parquet" | ||
| sqlContext.range(1 << 16).selectExpr("(id % 4) AS i") | ||
| .coalesce(1).write.mode("overwrite").parquet(path) | ||
|
|
||
| val blockMetadata = readFooter(new Path(path), hadoopConfiguration).getBlocks.asScala.head | ||
| val columnChunkMetadata = blockMetadata.getColumns.asScala.head | ||
|
|
||
| // If the file is written with version 2, this should include | ||
| // [[Encoding.RLE_DICTIONARY]] type. For version 1, it is Encoding.PLAIN_DICTIONARY | ||
|
Contributor
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. BTW, the |
||
| assert(columnChunkMetadata.getEncodings.contains(Encoding.RLE_DICTIONARY)) | ||
| } finally { | ||
|
|
||
|
Contributor
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. Nit: Remove this empty line. |
||
| // Manually clear the hadoop configuration for other tests. | ||
| hadoopConfiguration.clear() | ||
| clonedConf.asScala.foreach(entry => hadoopConfiguration.set(entry.getKey, entry.getValue)) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("read dictionary encoded decimals written as INT32") { | ||
| checkAnswer( | ||
| // Decimal column in this file is encoded using plain dictionary | ||
|
|
||
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.
Nit: Remove this empty line.