imback82 commented on a change in pull request #25247: [SPARK-28319][SQL] Implement SHOW TABLES for Data Source V2 Tables URL: https://github.com/apache/spark/pull/25247#discussion_r310341532
########## File path: sql/core/src/test/scala/org/apache/spark/sql/sources/v2/DataSourceV2SQLSuite.scala ########## @@ -1646,4 +1651,70 @@ class DataSourceV2SQLSuite extends QueryTest with SharedSQLContext with BeforeAn } } } + + test("ShowTables using v2 catalog") { + spark.sql("CREATE TABLE testcat.db.table_name (id bigint, data string) USING foo") + spark.sql("CREATE TABLE testcat.n1.n2.db.table_name (id bigint, data string) USING foo") + + { + val tables = runShowTablesSql("SHOW TABLES FROM testcat.db") + assert(tables === Seq(Row("db", "table_name", false))) + } + { + val tables = runShowTablesSql("SHOW TABLES FROM testcat.n1.n2.db") + assert(tables === Seq(Row("n1.n2.db", "table_name", false))) + } + } + + test("ShowTables using v2 catalog with a pattern") { + spark.sql("CREATE TABLE testcat.db.table (id bigint, data string) USING foo") + spark.sql("CREATE TABLE testcat.db.table_name_1 (id bigint, data string) USING foo") + spark.sql("CREATE TABLE testcat.db.table_name_2 (id bigint, data string) USING foo") + spark.sql("CREATE TABLE testcat.db2.table_name_2 (id bigint, data string) USING foo") + + { + val tables = runShowTablesSql("SHOW TABLES FROM testcat.db") + assert(tables === Seq( + Row("db", "table", false), + Row("db", "table_name_1", false), + Row("db", "table_name_2", false))) + } + { + val tables = runShowTablesSql("SHOW TABLES FROM testcat.db LIKE '*name*'") + assert(tables === Seq( + Row("db", "table_name_1", false), + Row("db", "table_name_2", false))) + } + { + val tables = runShowTablesSql("SHOW TABLES FROM testcat.db LIKE '*2'") + assert(tables === Seq(Row("db", "table_name_2", false))) + } + } + + test("ShowTables: using v2 catalog, db doesn't exist") { + val tables = runShowTablesSql("SHOW TABLES FROM testcat.unknown") + assert(tables.isEmpty) + } + + test("ShowTables: db is not specified - fallback to v1") { Review comment: Yes, you are right. I was waiting for your OK with the approach I suggested. I will update the tests now. Thanks! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org