-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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-22280][SQL][TEST] Improve StatisticsSuite to test convertMetastore
properly
#19500
Changes from 1 commit
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 |
---|---|---|
|
@@ -937,26 +937,22 @@ 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 => | ||
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? 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 => | ||
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. We prefer to using 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. Thank you for review, @gatorsmile . Sure. |
||
withSQLConf( | ||
HiveUtils.CONVERT_METASTORE_ORC.key -> isConverted, | ||
HiveUtils.CONVERT_METASTORE_PARQUET.key -> isConverted) { | ||
withTable(format) { | ||
sql(s"CREATE TABLE $format (key STRING, value STRING) STORED AS $format") | ||
sql(s"INSERT INTO TABLE $format SELECT * FROM src") | ||
|
||
val hasHiveStats = !isConverted.toBoolean | ||
checkTableStats(format, hasSizeInBytes = hasHiveStats, expectedRowCounts = None) | ||
|
||
sql(s"ANALYZE TABLE $format COMPUTE STATISTICS") | ||
checkTableStats(format, hasSizeInBytes = true, expectedRowCounts = Some(500)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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?
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.