-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22280][SQL][TEST] Improve StatisticsSuite to test convertMetastore properly
#19500
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -937,26 +937,20 @@ class StatisticsSuite extends StatisticsCollectionTestBase with TestHiveSingleto | |
| } | ||
|
|
||
| test("test statistics of LogicalRelation converted from Hive serde tables") { | ||
| val parquetTable = "parquetTable" | ||
| val orcTable = "orcTable" | ||
| withTable(parquetTable, orcTable) { | ||
| sql(s"CREATE TABLE $parquetTable (key STRING, value STRING) STORED AS PARQUET") | ||
| sql(s"CREATE TABLE $orcTable (key STRING, value STRING) STORED AS ORC") | ||
| sql(s"INSERT INTO TABLE $parquetTable SELECT * FROM src") | ||
| sql(s"INSERT INTO TABLE $orcTable SELECT * FROM src") | ||
|
|
||
| // the default value for `spark.sql.hive.convertMetastoreParquet` is true, here we just set it | ||
| // for robustness | ||
| withSQLConf(HiveUtils.CONVERT_METASTORE_PARQUET.key -> "true") { | ||
| checkTableStats(parquetTable, hasSizeInBytes = false, expectedRowCounts = None) | ||
| sql(s"ANALYZE TABLE $parquetTable COMPUTE STATISTICS") | ||
| checkTableStats(parquetTable, hasSizeInBytes = true, expectedRowCounts = Some(500)) | ||
| } | ||
| withSQLConf(HiveUtils.CONVERT_METASTORE_ORC.key -> "true") { | ||
| // We still can get tableSize from Hive before Analyze | ||
| checkTableStats(orcTable, hasSizeInBytes = true, expectedRowCounts = None) | ||
| sql(s"ANALYZE TABLE $orcTable COMPUTE STATISTICS") | ||
| checkTableStats(orcTable, hasSizeInBytes = true, expectedRowCounts = Some(500)) | ||
| Seq("orc", "parquet").foreach { format => | ||
|
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. Maybe "orcTbl" and "parquetTbl" are better?
Member
Author
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 is used in |
||
| Seq(true, false).foreach { isConverted => | ||
| withSQLConf( | ||
| HiveUtils.CONVERT_METASTORE_ORC.key -> s"$isConverted", | ||
| HiveUtils.CONVERT_METASTORE_PARQUET.key -> s"$isConverted") { | ||
| withTable(format) { | ||
| sql(s"CREATE TABLE $format (key STRING, value STRING) STORED AS $format") | ||
| sql(s"INSERT INTO TABLE $format SELECT * FROM src") | ||
|
|
||
| checkTableStats(format, hasSizeInBytes = !isConverted, expectedRowCounts = None) | ||
| sql(s"ANALYZE TABLE $format COMPUTE STATISTICS") | ||
| checkTableStats(format, hasSizeInBytes = true, expectedRowCounts = Some(500)) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you explain why orc table has size before analyze command while parquet table does not?
Uh oh!
There was an error while loading. Please reload this page.
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 old test case by SPARK-17410.
The original test case before SPARK-17410 wasn't and my new test case didn't.
It's due to
convertMetastoreXXX. Hive INSERT will generate stats.