-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-40733][SQL] Make the contents of SERDEPROPERTIES in the result of ShowCreateTableAsSerdeCommand have a fixed order
#38238
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
Conversation
|
Test first |
SERDEPROPERTIES in the ShowCreateTableAsSerdeCommand result have a fixed orderSERDEPROPERTIES in the result of ShowCreateTableAsSerdeCommand have a fixed order
| builder ++= s"ROW FORMAT SERDE '$serde'\n" | ||
|
|
||
| val serdeProps = conf.redactOptions(metadata.storage.properties).map { | ||
| val serdeProps = conf.redactOptions(metadata.storage.properties).toSeq.sortBy(_._1).map { |
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.
spark/sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala
Lines 1202 to 1210 in 1cb8250
| private def showDataSourceTableOptions(metadata: CatalogTable, builder: StringBuilder): Unit = { | |
| // For datasource table, there is a provider there in the metadata. | |
| // If it is a Hive table, we already convert its metadata and fill in a provider. | |
| builder ++= s"USING ${metadata.provider.get}\n" | |
| val dataSourceOptions = conf.redactOptions(metadata.storage.properties).toSeq.sortBy(_._1).map { | |
| case (key, value) => | |
| s"'${escapeSingleQuotedString(key)}' = '${escapeSingleQuotedString(value)}'" | |
| } |
showDataSourceTableOptions already do the similar work in #34753
dongjoon-hyun
left a comment
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, LGTM. Thank you, @LuciferYang .
Merged to master for Apache Spark 3.4.0.
|
Thanks @dongjoon-hyun |
…lt of `ShowCreateTableAsSerdeCommand` have a fixed order ### What changes were proposed in this pull request? This pr add a sort operation to make the contents of `SERDEPROPERTIES` in the result of `ShowCreateTableAsSerdeCommand` have a fixed order. ### Why are the changes needed? Improve Java version compatibility, make the results of `ShowCreateTableAsSerdeCommand` consistent when using Java version. Run the following command with Java 19: ``` mvn clean install -DskipTests -pl sql/hive -am mvn test -pl sql/hive -Dtest=none -DwildcardSuites=org.apache.spark.sql.hive.execution.command.ShowCreateTableSuite ``` There are 2 failed test: ``` - SHOW CREATE TABLE using Hive V1 catalog V1 command: hive table with serde info *** FAILED *** "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." did not equal "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." (ShowCreateTableSuite.scala:187) Analysis: "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." -> "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." - SHOW CREATE TABLE using Hive V1 catalog V2 command: hive table with serde info *** FAILED *** "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." did not equal "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." (ShowCreateTableSuite.scala:187) Analysis: "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." -> "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." ``` The content of `SERDEPROPERTIES` is correct, but the order is different from result running with Java 8/11/17. ### Does this PR introduce _any_ user-facing change? Yes, the `SERDEPROPERTIES` part of `ShowCreateTableAsSerdeCommand` results will be displayed in order by key. ### How was this patch tested? - Pass Git Hub Actions - Manual test: Run the following command with Java 19: ``` mvn clean install -DskipTests -pl sql/hive -am mvn test -pl sql/hive -Dtest=none -DwildcardSuites=org.apache.spark.sql.hive.execution.command.ShowCreateTableSuite ``` **Before** ``` - SHOW CREATE TABLE using Hive V1 catalog V1 command: hive table with serde info *** FAILED *** "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." did not equal "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." (ShowCreateTableSuite.scala:187) Analysis: "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." -> "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." - SHOW CREATE TABLE using Hive V1 catalog V2 command: hive table with serde info *** FAILED *** "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." did not equal "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." (ShowCreateTableSuite.scala:187) Analysis: "... SERDEPROPERTIES ( '[serialization.format' = '1', 'field.delim' = ',', 'mapkey].delim' = ',') STORE..." -> "... SERDEPROPERTIES ( '[mapkey.delim' = ',', 'serialization.format' = '1', 'field].delim' = ',') STORE..." ``` **After** ``` Run completed in 23 seconds, 930 milliseconds. Total number of tests run: 58 Suites: completed 2, aborted 0 Tests: succeeded 58, failed 0, canceled 0, ignored 0, pending 0 All tests passed. ``` Closes apache#38238 from LuciferYang/SPARK-40733. Authored-by: yangjie01 <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
What changes were proposed in this pull request?
This pr add a sort operation to make the contents of
SERDEPROPERTIESin the result ofShowCreateTableAsSerdeCommandhave a fixed order.Why are the changes needed?
Improve Java version compatibility, make the results of
ShowCreateTableAsSerdeCommandconsistent when using Java version.Run the following command with Java 19:
There are 2 failed test:
The content of
SERDEPROPERTIESis correct, but the order is different from result running with Java 8/11/17.Does this PR introduce any user-facing change?
Yes, the
SERDEPROPERTIESpart ofShowCreateTableAsSerdeCommandresults will be displayed in order by key.How was this patch tested?
Run the following command with Java 19:
Before
After