This is an automated email from the ASF dual-hosted git repository.
maxgekk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new 6edcafc8aa1 [SPARK-40891][SQL][TESTS] Check error classes in
TableIdentifierParserSuite
6edcafc8aa1 is described below
commit 6edcafc8aa114f53cb7c05666aacffd21b21dcaa
Author: panbingkun <[email protected]>
AuthorDate: Mon Oct 24 15:13:58 2022 +0500
[SPARK-40891][SQL][TESTS] Check error classes in TableIdentifierParserSuite
### What changes were proposed in this pull request?
his PR aims to replace 'intercept' with 'Check error classes' in
TableIdentifierParserSuite.
### Why are the changes needed?
The changes improve the error framework.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
By running the modified test suite:
```
$ build/sbt "test:testOnly *TableIdentifierParserSuite"
```
Closes #38364 from panbingkun/SPARK-40891.
Authored-by: panbingkun <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
---
.../parser/TableIdentifierParserSuite.scala | 26 ++++++++++++++++------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/TableIdentifierParserSuite.scala
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/TableIdentifierParserSuite.scala
index c2b240b3c49..62557ead1d2 100644
---
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/TableIdentifierParserSuite.scala
+++
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/TableIdentifierParserSuite.scala
@@ -290,8 +290,17 @@ class TableIdentifierParserSuite extends SQLKeywordUtils {
assert(TableIdentifier("q", Option("d")) === parseTableIdentifier("d.q"))
// Illegal names.
- Seq("", "d.q.g", "t:", "${some.var.x}", "tab:1").foreach { identifier =>
- intercept[ParseException](parseTableIdentifier(identifier))
+ Seq(
+ "" -> ("PARSE_EMPTY_STATEMENT", Map.empty[String, String]),
+ "d.q.g" -> ("PARSE_SYNTAX_ERROR", Map("error" -> "'.'", "hint" -> "")),
+ "t:" -> ("PARSE_SYNTAX_ERROR", Map("error" -> "':'", "hint" -> ": extra
input ':'")),
+ "${some.var.x}" -> ("PARSE_SYNTAX_ERROR", Map("error" -> "'$'", "hint"
-> "")),
+ "tab:1" -> ("PARSE_SYNTAX_ERROR", Map("error" -> "':'", "hint" -> ""))
+ ).foreach { case (identifier, (errorClass, parameters)) =>
+ checkError(
+ exception =
intercept[ParseException](parseTableIdentifier(identifier)),
+ errorClass = errorClass,
+ parameters = parameters)
}
}
@@ -307,10 +316,10 @@ class TableIdentifierParserSuite extends SQLKeywordUtils {
withSQLConf(SQLConf.ANSI_ENABLED.key -> "true",
SQLConf.ENFORCE_RESERVED_KEYWORDS.key -> "true") {
reservedKeywordsInAnsiMode.foreach { keyword =>
- val errMsg = intercept[ParseException] {
- parseTableIdentifier(keyword)
- }.getMessage
- assert(errMsg.contains("Syntax error at or near"))
+ checkError(
+ exception = intercept[ParseException](parseTableIdentifier(keyword)),
+ errorClass = "PARSE_SYNTAX_ERROR",
+ parameters = Map("error" -> s"'$keyword'", "hint" -> ""))
assert(TableIdentifier(keyword) ===
parseTableIdentifier(s"`$keyword`"))
assert(TableIdentifier(keyword, Option("db")) ===
parseTableIdentifier(s"db.`$keyword`"))
}
@@ -363,7 +372,10 @@ class TableIdentifierParserSuite extends SQLKeywordUtils {
val complexName = TableIdentifier("`weird`table`name", Some("`d`b`1"))
assert(complexName ===
parseTableIdentifier("```d``b``1`.```weird``table``name`"))
assert(complexName === parseTableIdentifier(complexName.quotedString))
- intercept[ParseException](parseTableIdentifier(complexName.unquotedString))
+ checkError(
+ exception =
intercept[ParseException](parseTableIdentifier(complexName.unquotedString)),
+ errorClass = "PARSE_SYNTAX_ERROR",
+ parameters = Map("error" -> "'b'", "hint" -> ""))
// Table identifier contains continuous backticks should be treated
correctly.
val complexName2 = TableIdentifier("x``y", Some("d``b"))
assert(complexName2 === parseTableIdentifier(complexName2.quotedString))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]