Skip to content
Prev Previous commit
Next Next commit
[SPARK-22954][SQL] Fixed the test to test for AnalysisException inste…
…ad of NoSuchTableException
  • Loading branch information
su225 committed Jan 7, 2018
commit 98b8711cdd26c25fd774f77f46fc9e395ee2cffe
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.apache.spark.sql.execution
import org.apache.spark.sql._
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.analysis.NoSuchTableException
import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.test.{SharedSQLContext, SQLTestUtils}

class SimpleSQLViewSuite extends SQLViewSuite with SharedSQLContext
Expand Down Expand Up @@ -154,11 +155,17 @@ abstract class SQLViewSuite extends QueryTest with SQLTestUtils {
assertNoSuchTable(s"TRUNCATE TABLE $viewName")
assertNoSuchTable(s"SHOW CREATE TABLE $viewName")
assertNoSuchTable(s"SHOW PARTITIONS $viewName")
assertNoSuchTable(s"ANALYZE TABLE $viewName COMPUTE STATISTICS")
assertNoSuchTable(s"ANALYZE TABLE $viewName COMPUTE STATISTICS FOR COLUMNS id")
assertAnalysisException(s"ANALYZE TABLE $viewName COMPUTE STATISTICS")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also check the error message to ensure the AnalysisException is not thrown from elsewhere.

assertAnalysisException(s"ANALYZE TABLE $viewName COMPUTE STATISTICS FOR COLUMNS id")
}
}


private def assertAnalysisException(query: String): Unit = {
intercept[AnalysisException] {
sql(query)
}
}

private def assertNoSuchTable(query: String): Unit = {
intercept[NoSuchTableException] {
sql(query)
Expand Down