From 610c6770b20b8c729a49cacf348a620e65e52379 Mon Sep 17 00:00:00 2001 From: Terry Kim Date: Tue, 15 Dec 2020 22:09:36 -0800 Subject: [PATCH 1/2] initial commit --- .../spark/sql/catalyst/analysis/CheckAnalysis.scala | 6 +++--- .../org/apache/spark/sql/StatisticsCollectionSuite.scala | 2 +- .../apache/spark/sql/connector/DataSourceV2SQLSuite.scala | 4 ++-- .../org/apache/spark/sql/execution/SQLViewSuite.scala | 4 ++-- .../datasources/v2/jdbc/JDBCTableCatalogSuite.scala | 8 ++++---- .../spark/sql/hive/execution/HiveCommandSuite.scala | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala index 30467685d75a9..c5a63546c01e3 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala @@ -102,7 +102,7 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog { u.failAnalysis(s"Namespace not found: ${u.multipartIdentifier.quoted}") case u: UnresolvedTable => - u.failAnalysis(s"Table not found for '${u.commandName}': ${u.multipartIdentifier.quoted}") + u.failAnalysis(s"Table not found: ${u.multipartIdentifier.quoted}") case u @ UnresolvedView(NonSessionCatalogAndIdentifier(catalog, ident), cmd, _, _) => u.failAnalysis( @@ -111,12 +111,12 @@ trait CheckAnalysis extends PredicateHelper with LookupCatalog { s"$cmd expects a view.") case u: UnresolvedView => - u.failAnalysis(s"View not found for '${u.commandName}': ${u.multipartIdentifier.quoted}") + u.failAnalysis(s"View not found: ${u.multipartIdentifier.quoted}") case u: UnresolvedTableOrView => val viewStr = if (u.allowTempView) "view" else "permanent view" u.failAnalysis( - s"Table or $viewStr not found for '${u.commandName}': ${u.multipartIdentifier.quoted}") + s"Table or $viewStr not found: ${u.multipartIdentifier.quoted}") case u: UnresolvedRelation => u.failAnalysis(s"Table or view not found: ${u.multipartIdentifier.quoted}") diff --git a/sql/core/src/test/scala/org/apache/spark/sql/StatisticsCollectionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/StatisticsCollectionSuite.scala index 3fc679f6b9fc7..3b53a5324445b 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/StatisticsCollectionSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/StatisticsCollectionSuite.scala @@ -542,7 +542,7 @@ class StatisticsCollectionSuite extends StatisticsCollectionTestBase with Shared val errMsg1 = intercept[AnalysisException] { sql(s"ANALYZE TABLE $globalTempDB.gTempView COMPUTE STATISTICS FOR COLUMNS id") }.getMessage - assert(errMsg1.contains("Table or view not found for 'ANALYZE TABLE ... FOR COLUMNS ...': " + + assert(errMsg1.contains("Table or view not found: " + s"$globalTempDB.gTempView")) // Analyzes in a global temporary view sql("CREATE GLOBAL TEMP VIEW gTempView AS SELECT * FROM range(1, 30)") diff --git a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala index 638f06d618833..b49a692d26173 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala @@ -731,7 +731,7 @@ class DataSourceV2SQLSuite val ex = intercept[AnalysisException] { sql("DROP TABLE testcat.db.notbl") } - assert(ex.getMessage.contains("Table or view not found for 'DROP TABLE': testcat.db.notbl")) + assert(ex.getMessage.contains("Table or view not found: testcat.db.notbl")) sql("DROP TABLE IF EXISTS testcat.db.notbl") } @@ -2015,7 +2015,7 @@ class DataSourceV2SQLSuite sql(s"ALTER VIEW testcat.ns.tbl RENAME TO ns.view") } assert(e.getMessage.contains( - "Table or view not found for 'ALTER VIEW ... RENAME TO': testcat.ns.tbl")) + "Table or view not found: testcat.ns.tbl")) } test("ANALYZE TABLE") { diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala index 1a248fc18988a..586b31643049f 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala @@ -452,11 +452,11 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils { test("should not allow ALTER VIEW AS when the view does not exist") { assertAnalysisError( "ALTER VIEW testView AS SELECT 1, 2", - "View not found for 'ALTER VIEW ... AS': testView") + "View not found: testView") assertAnalysisError( "ALTER VIEW default.testView AS SELECT 1, 2", - "View not found for 'ALTER VIEW ... AS': default.testView") + "View not found: default.testView") } test("ALTER VIEW AS should try to alter temp view first if view name has no database part") { diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala index e764f71867426..2fd976e0b9e17 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCTableCatalogSuite.scala @@ -81,9 +81,9 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession { checkAnswer(sql("SHOW TABLES IN h2.test"), Seq(Row("test", "people"))) Seq( "h2.test.not_existing_table" -> - "Table or view not found for 'DROP TABLE': h2.test.not_existing_table", + "Table or view not found: h2.test.not_existing_table", "h2.bad_test.not_existing_table" -> - "Table or view not found for 'DROP TABLE': h2.bad_test.not_existing_table" + "Table or view not found: h2.bad_test.not_existing_table" ).foreach { case (table, expectedMsg) => val msg = intercept[AnalysisException] { sql(s"DROP TABLE $table") @@ -110,12 +110,12 @@ class JDBCTableCatalogSuite extends QueryTest with SharedSparkSession { sql("ALTER TABLE h2.test.not_existing_table RENAME TO test.dst_table") } assert(exp1.getMessage.contains( - "Table or view not found for 'ALTER TABLE ... RENAME TO': h2.test.not_existing_table")) + "Table or view not found: h2.test.not_existing_table")) val exp2 = intercept[AnalysisException] { sql("ALTER TABLE h2.bad_test.not_existing_table RENAME TO test.dst_table") } assert(exp2.getMessage.contains( - "Table or view not found for 'ALTER TABLE ... RENAME TO': h2.bad_test.not_existing_table")) + "Table or view not found: h2.bad_test.not_existing_table")) // Rename to an existing table withTable("h2.test.dst_table") { withConnection { conn => diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveCommandSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveCommandSuite.scala index 4feb970ea6f1a..d3398842afb21 100644 --- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveCommandSuite.scala +++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveCommandSuite.scala @@ -137,7 +137,7 @@ class HiveCommandSuite extends QueryTest with SQLTestUtils with TestHiveSingleto val message = intercept[AnalysisException] { sql("SHOW TBLPROPERTIES badtable") }.getMessage - assert(message.contains("Table or view not found for 'SHOW TBLPROPERTIES': badtable")) + assert(message.contains("Table or view not found: badtable")) // When key is not found, a row containing the error is returned. checkAnswer( From 73081c1f2a3444bada8f9a0afa957166a0eb1efe Mon Sep 17 00:00:00 2001 From: Terry Kim Date: Wed, 16 Dec 2020 00:32:19 -0800 Subject: [PATCH 2/2] Fix tests for show columns --- .../test/resources/sql-tests/results/show_columns.sql.out | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/core/src/test/resources/sql-tests/results/show_columns.sql.out b/sql/core/src/test/resources/sql-tests/results/show_columns.sql.out index 851e848ed4ec6..3535b30d29c44 100644 --- a/sql/core/src/test/resources/sql-tests/results/show_columns.sql.out +++ b/sql/core/src/test/resources/sql-tests/results/show_columns.sql.out @@ -94,7 +94,7 @@ SHOW COLUMNS IN badtable FROM showdb struct<> -- !query output org.apache.spark.sql.AnalysisException -Table or view not found for 'SHOW COLUMNS': showdb.badtable; line 1 pos 0 +Table or view not found: showdb.badtable; line 1 pos 0 -- !query @@ -130,7 +130,7 @@ SHOW COLUMNS IN showdb.showcolumn3 struct<> -- !query output org.apache.spark.sql.AnalysisException -Table or view not found for 'SHOW COLUMNS': showdb.showcolumn3; line 1 pos 0 +Table or view not found: showdb.showcolumn3; line 1 pos 0 -- !query @@ -139,7 +139,7 @@ SHOW COLUMNS IN showcolumn3 FROM showdb struct<> -- !query output org.apache.spark.sql.AnalysisException -Table or view not found for 'SHOW COLUMNS': showdb.showcolumn3; line 1 pos 0 +Table or view not found: showdb.showcolumn3; line 1 pos 0 -- !query @@ -148,7 +148,7 @@ SHOW COLUMNS IN showcolumn4 struct<> -- !query output org.apache.spark.sql.AnalysisException -Table or view not found for 'SHOW COLUMNS': showcolumn4; line 1 pos 0 +Table or view not found: showcolumn4; line 1 pos 0 -- !query