-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-21599][SQL] Collecting column statistics for datasource tables may fail with java.util.NoSuchElementException #18804
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 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0afefd5
[SPARK-21599] Collecting column statistics for datasource tables may …
dilipbiswal 420be2f
Code review comments
dilipbiswal 80b0073
Add new test for hive serde tables
dilipbiswal 385dfbe
Code review comments.
dilipbiswal 7a8fa2c
code review
dilipbiswal c1ab569
style
dilipbiswal a120357
Enhance test
dilipbiswal 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
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 |
|---|---|---|
|
|
@@ -117,6 +117,26 @@ class StatisticsSuite extends StatisticsCollectionTestBase with TestHiveSingleto | |
| } | ||
| } | ||
|
|
||
| test("analyze non hive compatible datasource tables") { | ||
| val table = "parquet_tab" | ||
| withTable(table) { | ||
| sql( | ||
| s""" | ||
| |CREATE TABLE $table (a int, b int) | ||
| |USING parquet | ||
| |OPTIONS (skipHiveMetadata true) | ||
| """.stripMargin) | ||
| sql(s"insert into $table values (1, 1)") | ||
| sql(s"insert into $table values (2, 1)") | ||
|
Member
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. nit: minor style issue. |
||
| sql(s"ANALYZE TABLE $table COMPUTE STATISTICS FOR COLUMNS a, b") | ||
| val fetchedStats0 = | ||
| checkTableStats(table, hasSizeInBytes = true, expectedRowCounts = Some(2)) | ||
| assert(fetchedStats0.get.colStats == Map( | ||
| "a" -> ColumnStat(2, Some(1), Some(2), 0, 4, 4), | ||
| "b" -> ColumnStat(1, Some(1), Some(1), 0, 4, 4))) | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-21079 - analyze table with location different than that of individual partitions") { | ||
| val tableName = "analyzeTable_part" | ||
| withTable(tableName) { | ||
|
|
||
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.
For Hive serde tables that were created by Spark 2.1 or later, we should still restore it from table properties.
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.
See the code in https://github.com/apache/spark/blob/master/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala#L755-L758
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.
Maybe call
restoreTableMetadatato avoid duplicate logic.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.
should we call getTable().schema or you guys think its too verbose ?
val schema = getTable(db, table).schema ?
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.
@viirya Actually, we do have a raw table here.. so i will just call restoreTableMetadata. Thanks a lot @gatorsmile and @viirya
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.
You still need
rawTable. CallgetTablewill incur another metastore access.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.
@viirya right. I agree. I was saying that we do have a raw table from a prior call. So here we just pass that to restoreTableMetadata like you suggested.
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.
Yeah, I saw your comment #18804 (comment) after post #18804 (comment). :)