-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24570][SQL] Implement Spark own GetTablesOperation to fix SQL client tools cannot show tables #22794
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
[SPARK-24570][SQL] Implement Spark own GetTablesOperation to fix SQL client tools cannot show tables #22794
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9f528bc
Fix SQL client tools cannot show schemas/tables
wangyum 2939178
Add test
wangyum 8449cdf
Implement GetTablesOperation
wangyum e9a2a93
Only correct tableType constructor rowData
wangyum 80a8d21
Add SparkMetadataOperationSuite
wangyum 80bddb8
Merge remote-tracking branch 'upstream/master' into SPARK-24570
wangyum 4f5cd27
Change RowSet to protected
wangyum fb7e0a5
remove s
wangyum 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
Change RowSet to protected
- Loading branch information
commit 4f5cd273c220701c03362eedbbff4425da9f2f29
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
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 |
|---|---|---|
|
|
@@ -102,7 +102,7 @@ class SparkMetadataOperationSuite extends HiveThriftJdbcTest { | |
| } | ||
|
|
||
| test("Spark's own GetTablesOperation(SparkGetTablesOperation)") { | ||
|
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. This test mimic |
||
| def testGetSchemasOperation(( | ||
| def testGetTablesOperation( | ||
| schema: String, | ||
| tableNamePattern: String, | ||
| tableTypes: JList[String])(f: HiveQueryResultSet => Unit): Unit = { | ||
|
|
@@ -155,31 +155,32 @@ class SparkMetadataOperationSuite extends HiveThriftJdbcTest { | |
| } | ||
|
|
||
| withJdbcStatement("table1", "table2") { statement => | ||
| Seq("CREATE TABLE table1(key INT, val STRING)", | ||
| Seq( | ||
| "CREATE TABLE table1(key INT, val STRING)", | ||
| "CREATE TABLE table2(key INT, val STRING)", | ||
| "CREATE VIEW view1 AS SELECT * FROM table2").foreach(statement.execute) | ||
|
|
||
| testGetSchemasOperation("%", "%", null) { rs => | ||
| testGetTablesOperation("%", "%", null) { rs => | ||
| checkResult(Seq("table1", "table2", "view1"), rs) | ||
| } | ||
|
|
||
| testGetSchemasOperation("%", "table1", null) { rs => | ||
| testGetTablesOperation("%", "table1", null) { rs => | ||
| checkResult(Seq("table1"), rs) | ||
| } | ||
|
|
||
| testGetSchemasOperation("%", "table_not_exist", null) { rs => | ||
| testGetTablesOperation("%", "table_not_exist", null) { rs => | ||
| checkResult(Seq.empty, rs) | ||
| } | ||
|
|
||
| testGetSchemasOperation("%", "%", JArrays.asList("TABLE")) { rs => | ||
| testGetTablesOperation("%", "%", JArrays.asList("TABLE")) { rs => | ||
| checkResult(Seq("table1", "table2"), rs) | ||
| } | ||
|
|
||
| testGetSchemasOperation("%", "%", JArrays.asList("VIEW")) { rs => | ||
| testGetTablesOperation("%", "%", JArrays.asList("VIEW")) { rs => | ||
| checkResult(Seq("view1"), rs) | ||
| } | ||
|
|
||
| testGetSchemasOperation("%", "%", JArrays.asList("TABLE", "VIEW")) { rs => | ||
| testGetTablesOperation("%", "%", JArrays.asList("TABLE", "VIEW")) { rs => | ||
| checkResult(Seq("table1", "table2", "view1"), rs) | ||
| } | ||
| } | ||
|
|
||
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.
This can be very slow for big schemas. Calling
getTableMetadataon every table will trigger 3 separate database calls to the metastore (requireDbExists, requireTableExists, and getTable) taking ~tens of ms for every table. So it can be tens of seconds for schemas with hundreds of tables.The underlying Hive Thriftserver GetTables uses MetastoreClient.getTableObjectsByName (https://hive.apache.org/javadocs/r2.1.1/api/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.html#getTableObjectsByName-java.lang.String-java.util.List-) call to bulk-list the tables, but we don't expose that through our SessionCatalog / ExternalCatalog / HiveClientImpl
Would it be possible to thread that bulk getTableObjectsByName operation through our catalog APIs, to be able to retrieve the tables efficiently here? @wangyum @gatorsmile - what do you think?
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 raised https://issues.apache.org/jira/browse/SPARK-27899 with this idea.
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.
@LantaoJin @wangyum Could either of you submit a PR to resolve the issue raised by @juliuszsompolski ?
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 take this issue.