You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/10/31 06:52:47 UTC
[GitHub] [spark] MaxGekk commented on a diff in pull request #38439: [SPARK-40890][SQL][TESTS] Check error classes in DataSourceV2SQLSuite
MaxGekk commented on code in PR #38439:
URL: https://github.com/apache/spark/pull/38439#discussion_r1009078448
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -63,11 +65,15 @@ abstract class DataSourceV2SQLSuite
protected def assertAnalysisError(
sqlStatement: String,
- expectedError: String): Unit = {
- val ex = intercept[AnalysisException] {
- sql(sqlStatement)
- }
- assert(ex.getMessage.contains(expectedError))
+ errorClass: String,
+ parameters: Map[String, String]): Unit = {
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql(sqlStatement)
+ },
+ errorClass = errorClass,
+ parameters = parameters
+ )
Review Comment:
Let's introduce a helper method for this:
```scala
exception = intercept[AnalysisException] {
sql(sqlStatement)
},
```
and invoke `checkError` directly.
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala:
##########
@@ -2428,23 +2719,38 @@ class DataSourceV2SQLSuiteV1Filter extends DataSourceV2SQLSuite with AlterTableT
}
private def testNotSupportedV2Command(sqlCommand: String, sqlParams: String): Unit = {
- val e = intercept[AnalysisException] {
- sql(s"$sqlCommand $sqlParams")
- }
- assert(e.message.contains(s"$sqlCommand is not supported for v2 tables"))
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql(s"$sqlCommand $sqlParams")
+ },
+ errorClass = "_LEGACY_ERROR_TEMP_1124",
+ parameters = Map("cmd" -> sqlCommand))
}
private def assertAnalysisErrorClass(
Review Comment:
Let's remove `assertAnalysisErrorClass()`, and use `checkError()` directly. You could introduce an method `analysisException` as we did before for ParseException
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org