Skip to content
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-20937][DOCS] Describe spark.sql.parquet.writeLegacyFormat property in Spark SQL, DataFrames and Datasets Guide #22453

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/sql-programming-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,17 @@ Configuration of Parquet can be done using the `setConf` method on `SparkSession
</p>
</td>
</tr>
<tr>
<td><code>spark.sql.parquet.writeLegacyFormat</code></td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go with the other parquet properties if anything, but, this one is so old I don't think it's worth documenting. It shouldn't be used today.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@srowen, actually, this configuration specifically related with compatibility with other systems like Impala (not only old Spark ones) where decimals are written based on fixed binary format (nowdays it's written in int-based in Spark). If this configurations is not enabled, they are unable to read what Spark wrote.

Given https://stackoverflow.com/questions/44279870/why-cant-impala-read-parquet-files-after-spark-sqls-write and JIRA like SPARK-20297, I think this configuration is kind of important. I even expected more documentation about this configuration specifically at the first place.

Personally I have been thinking it would better to leave this configuration after 3.0 as well for better compatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, of course, something we should remove in long term but my impression is that it's better to expose and explicitly mention we deprecate this later, and the remove it out.

I already argued a bit (for instance in SPARK-20297) to explain how to workaround and why it is. Was thinking it's better document this and reduce such overhead at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to add my 2 cents. We use both Spark and Hive in our Hadoop/Spark clusters. And we have 2 types of tables, working tables and target tables. Working tables are only used by Spark jobs, while target tables are populated by Spark and exposed to downstream jobs including Hive jobs. Our data engineers frequently meet with this issue when they use Hive to read target tables. Finally we decided to set spark.sql.parquet.writeLegacyFormat=true as the default value for target tables and explicitly describe this in our internal developer guide.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK that sounds important to document. But the reasoning in this thread is also more useful information I think. Instead of describing it as a legacy format (implying it's not valid Parquet or something) and that it's required for Hive and Impala, can we mention or point to the specific reason that would cause you to need this? The value of the documentation here is in whether it helps the user know when to set it one way or the other.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++1 for more information actually.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will update the doc and describe scenarios and reasons why we need this flag.

<td>false</td>
<td>
If true, data will be written in a way of Spark 1.4 and earlier. For example, decimal values
will be written in Apache Parquet's fixed-length byte array format, which other systems such as
Apache Hive and Apache Impala use. If false, the newer format in Parquet will be used. For
example, decimals will be written in int-based format. If Parquet output is intended for use
with systems that do not support this newer format, set to true.
</td>
</tr>
</table>

## ORC Files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,11 @@ object SQLConf {
.createWithDefault(10)

val PARQUET_WRITE_LEGACY_FORMAT = buildConf("spark.sql.parquet.writeLegacyFormat")
.doc("Whether to be compatible with the legacy Parquet format adopted by Spark 1.4 and prior " +
"versions, when converting Parquet schema to Spark SQL schema and vice versa.")
.doc("If true, data will be written in a way of Spark 1.4 and earlier. For example, decimal " +
"values will be written in Apache Parquet's fixed-length byte array format, which other " +
"systems such as Apache Hive and Apache Impala use. If false, the newer format in Parquet " +
"will be used. For example, decimals will be written in int-based format. If Parquet " +
"output is intended for use with systems that do not support this newer format, set to true.")
.booleanConf
.createWithDefault(false)

Expand Down