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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]