-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33382][SQL][TESTS] Unify datasource v1 and v2 SHOW TABLES tests #30287
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
Show all changes
47 commits
Select commit
Hold shift + click to select a range
58f4134
Draft of ShowTablesSuite
MaxGekk 7b8746f
ShowTablesSuite for v2
MaxGekk 4c0d2b8
test "show table in a not existing namespace"
MaxGekk f1aa46c
test "show an existing table in V1 catalog"
MaxGekk 3a85ac3
Move "ShowTables: using v2 catalog" to v2/ShowTablesSuite
MaxGekk 0534480
Move v2 pattern tests
MaxGekk 7c12702
Move more v1 tests
MaxGekk 327179e
Move more v2 tests
MaxGekk c07e08b
Move "namespace not specified and default v2 catalog not set - fallba…
MaxGekk 7738473
Move "SHOW TABLE EXTENDED valid v1"
MaxGekk 91521ce
Move "SHOW TABLE EXTENDED not valid v1 database"
MaxGekk 79b0fd0
Introduce ShowRow
MaxGekk e282bb5
Move "show tables with a pattern" to common trait
MaxGekk 70a578d
Remove duplicate tests
MaxGekk d21dd5e
Move "SHOW TABLE EXTENDED for default" to the common trait
MaxGekk 48509fb
Change default USING in v2
MaxGekk b5a6187
Add a comment for "show tables in nested namespaces"
MaxGekk bdc249a
Add comment for "show table in a not existing namespace"
MaxGekk ef2b536
Remove duplicate test from v1
MaxGekk 122faa5
Move SHOW VIEWS test back to DataSourceV2SQLSuite
MaxGekk 3016f69
Add comment for the test "using v2 catalog with empty namespace"
MaxGekk 53d0c77
Add comment for the test "namespace is not specified and default v2 c…
MaxGekk ebfa670
Add comment for the test "SHOW TABLE EXTENDED not valid v1 database"
MaxGekk dbf8e76
Minor: fix test titles
MaxGekk 1829685
Move a show view test back to DataSourceV2SQLSuite
MaxGekk 7d3b4b2
Fix test title
MaxGekk 80eb4a8
Refactoring
MaxGekk f0152e6
Minor changes
MaxGekk 8e55686
Using foo -> Using _
MaxGekk 4364a02
Remove beforeAll()
MaxGekk 529a858
Move parsing tests to the common trait
MaxGekk 947c8bc
Move the current catalog test
MaxGekk dd1f335
Add "TODO(SPARK-33393): Support SHOW TABLE EXTENDED in DSv2"
MaxGekk 70922c7
Add "TODO(SPARK-33394): Throw `NoSuchDatabaseException` for not exist…
MaxGekk a62486f
Use CatalogManager.SESSION_CATALOG_NAME
MaxGekk b608f8b
Move parsing tests to ShowTablesParserSuite
MaxGekk 3a3bc57
Move the SHOW TABLE EXTENDED test out from the common trait
MaxGekk 1c7f63c
Split the test "namespace is not specified and the default catalog is…
MaxGekk 3d82b4e
Add TODO(SPARK-33403)
MaxGekk d264962
Adjust test title
MaxGekk 286e11a
Move withSourceViews() out from the common trait
MaxGekk aafa7f8
refine tests
cloud-fan 6286152
Merge pull request #28 from cloud-fan/help
MaxGekk 94b337d
Override test()
MaxGekk 5f37a4c
Remove some parent classes
MaxGekk ca2f96a
Refactoring
MaxGekk 8108cb1
Remove an unused import
MaxGekk 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
76 changes: 76 additions & 0 deletions
76
sql/core/src/test/scala/org/apache/spark/sql/execution/command/ShowTablesParserSuite.scala
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 |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.execution.command | ||
|
|
||
| import org.apache.spark.sql.catalyst.analysis.{AnalysisTest, UnresolvedNamespace} | ||
| import org.apache.spark.sql.catalyst.parser.CatalystSqlParser.parsePlan | ||
| import org.apache.spark.sql.catalyst.plans.logical.{ShowTables, ShowTableStatement} | ||
| import org.apache.spark.sql.test.SharedSparkSession | ||
|
|
||
| class ShowTablesParserSuite extends AnalysisTest with SharedSparkSession { | ||
| private val catalog = "test_catalog" | ||
|
|
||
| test("show tables") { | ||
| comparePlans( | ||
| parsePlan("SHOW TABLES"), | ||
| ShowTables(UnresolvedNamespace(Seq.empty[String]), None)) | ||
| comparePlans( | ||
| parsePlan("SHOW TABLES '*test*'"), | ||
| ShowTables(UnresolvedNamespace(Seq.empty[String]), Some("*test*"))) | ||
| comparePlans( | ||
| parsePlan("SHOW TABLES LIKE '*test*'"), | ||
| ShowTables(UnresolvedNamespace(Seq.empty[String]), Some("*test*"))) | ||
| comparePlans( | ||
| parsePlan(s"SHOW TABLES FROM $catalog.ns1.ns2.tbl"), | ||
| ShowTables(UnresolvedNamespace(Seq(catalog, "ns1", "ns2", "tbl")), None)) | ||
| comparePlans( | ||
| parsePlan(s"SHOW TABLES IN $catalog.ns1.ns2.tbl"), | ||
| ShowTables(UnresolvedNamespace(Seq(catalog, "ns1", "ns2", "tbl")), None)) | ||
| comparePlans( | ||
| parsePlan("SHOW TABLES IN ns1 '*test*'"), | ||
| ShowTables(UnresolvedNamespace(Seq("ns1")), Some("*test*"))) | ||
| comparePlans( | ||
| parsePlan("SHOW TABLES IN ns1 LIKE '*test*'"), | ||
| ShowTables(UnresolvedNamespace(Seq("ns1")), Some("*test*"))) | ||
| } | ||
|
|
||
| test("show table extended") { | ||
| comparePlans( | ||
| parsePlan("SHOW TABLE EXTENDED LIKE '*test*'"), | ||
| ShowTableStatement(None, "*test*", None)) | ||
| comparePlans( | ||
| parsePlan(s"SHOW TABLE EXTENDED FROM $catalog.ns1.ns2 LIKE '*test*'"), | ||
| ShowTableStatement(Some(Seq(catalog, "ns1", "ns2")), "*test*", None)) | ||
| comparePlans( | ||
| parsePlan(s"SHOW TABLE EXTENDED IN $catalog.ns1.ns2 LIKE '*test*'"), | ||
| ShowTableStatement(Some(Seq(catalog, "ns1", "ns2")), "*test*", None)) | ||
| comparePlans( | ||
| parsePlan("SHOW TABLE EXTENDED LIKE '*test*' PARTITION(ds='2008-04-09', hr=11)"), | ||
| ShowTableStatement(None, "*test*", Some(Map("ds" -> "2008-04-09", "hr" -> "11")))) | ||
| comparePlans( | ||
| parsePlan(s"SHOW TABLE EXTENDED FROM $catalog.ns1.ns2 LIKE '*test*' " + | ||
| "PARTITION(ds='2008-04-09')"), | ||
| ShowTableStatement(Some(Seq(catalog, "ns1", "ns2")), "*test*", | ||
| Some(Map("ds" -> "2008-04-09")))) | ||
| comparePlans( | ||
| parsePlan(s"SHOW TABLE EXTENDED IN $catalog.ns1.ns2 LIKE '*test*' " + | ||
| "PARTITION(ds='2008-04-09')"), | ||
| ShowTableStatement(Some(Seq(catalog, "ns1", "ns2")), "*test*", | ||
| Some(Map("ds" -> "2008-04-09")))) | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
@imback82 do you know why we still have
ShowTableStatementhere?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.
We parse
SHOW TABLE EXTENDED:spark/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
Lines 211 to 212 in ccc0250
and convert it to
ShowTableStatement:spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
Lines 2929 to 2934 in 0ad35ba
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.
@cloud-fan
ShowTableis not migrated yet; onlyShowTableswith "s" is migrated. I will work on this migration soon.