-
Notifications
You must be signed in to change notification settings - Fork 28k
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
Changes from 2 commits
3af33a3
e6f67c1
6e2680f
3e51bd9
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1002,6 +1002,21 @@ Configuration of Parquet can be done using the `setConf` method on `SparkSession | |||||||||||||||||||
</p> | ||||||||||||||||||||
</td> | ||||||||||||||||||||
</tr> | ||||||||||||||||||||
<tr> | ||||||||||||||||||||
<td><code>spark.sql.parquet.writeLegacyFormat</code></td> | ||||||||||||||||||||
<td>false</td> | ||||||||||||||||||||
<td> | ||||||||||||||||||||
This configuration indicates whether we should use legacy Parquet format adopted by Spark 1.4 | ||||||||||||||||||||
and prior versions or the standard format defined in parquet-format specification to write | ||||||||||||||||||||
Parquet files. This is not only related to compatibility with old Spark ones, but also other | ||||||||||||||||||||
systems like Hive, Impala, Presto, etc. This is especially important for decimals. If this | ||||||||||||||||||||
configuration is not enabled, decimals will be written in int-based format in Spark 1.5 and | ||||||||||||||||||||
above, other systems that only support legacy decimal format (fixed length byte array) will not | ||||||||||||||||||||
be able to read what Spark has written. Note other systems may have added support for the | ||||||||||||||||||||
standard format in more recent versions, which will make this configuration unnecessary. Please | ||||||||||||||||||||
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. Yeah, I think Hive and Impala also use newer Parquet versions/format. Isn't it sufficient to say older versions of Spark (<= 1.4) and older versions of Hive, Impala (do we know which?) use older Parquet formats and this enables writing it that way? 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 haven't checked closely but I think Hive still uses binary for decimals (https://github.com/apache/hive/blob/ae008b79b5d52ed6a38875b73025a505725828eb/ql/src/java/org/apache/hadoop/hive/ql/io/parquet/write/DataWritableWriter.java#L503-L541). Given my past investigation, thing is, Parquet supports both ways to write out (https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#decimal) IIRC. They deprecated timestamp based on int 96 (https://github.com/apache/parquet-format/blob/master/src/main/thrift/parquet.thrift#L782) but not decimals. 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 think it somehow leads to confusion since we call the option something "legacy" which isn't actually legacy in Parquet's decimal side. 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. Hive and Impala do NOT support new Parquet format yet.
Presto began to support new Parquet format since 0.182.
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. It sounds like it isn't quite a legacy format, but one still used by Hive and even considered valid if not current by Parquet? This part I am not sure of, but basing it on Hyukjin's comment above. I suggest a somewhat shorter text like this, what do you think? its length would be more suitable as a config doc below. If 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. If we must call it "legacy", I'd think of it legacy implementation in Spark side, rather than legacy format in Parquet side.
Anyway, it really leads to confusion. Really appreciate your suggestion @srowen to make the doc shorter, the doc you suggested is more concise and to the point. One more thing I want to discuss. After investigating the usage of this option, I found this option is not only related to decimals, but also complex types (Array, Map), see below source code. Should we mention this in the doc? Lines 450 to 458 in 473d0d8
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. Let's make it short and get rid of all other things orthogonal with the issue itself (I think the issue is specific to decimals). For instance, we could say (based upon Sean's comment): If Please feel free to change words as what you think is righter 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, let's match the doc in 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. Thanks for your suggestion. I have updated the doc in SQLConf. |
||||||||||||||||||||
consult documentation of related systems for details. | ||||||||||||||||||||
</td> | ||||||||||||||||||||
</tr> | ||||||||||||||||||||
</table> | ||||||||||||||||||||
|
||||||||||||||||||||
## ORC Files | ||||||||||||||||||||
|
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 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.
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.
@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.
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, 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.
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'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.
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.
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.
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.
++1 for more information actually.
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.
OK, I will update the doc and describe scenarios and reasons why we need this flag.