1
0

[HUDI-4325] fix spark sql procedure cause ParseException with semicolon (#5982)

* [HUDI-4325] fix saprk sql procedure cause ParseException with semicolon
This commit is contained in:
KnightChess
2022-06-28 09:44:41 +08:00
committed by GitHub
parent b14ed47f21
commit 09dc001430
2 changed files with 21 additions and 1 deletions

View File

@@ -42,7 +42,7 @@
}
singleStatement
: statement EOF
: statement ';'* EOF
;
statement

View File

@@ -85,6 +85,26 @@ class TestCallCommandParser extends HoodieSparkSqlTestBase {
checkParseExceptionContain("CALL cat.system radish kebab")("mismatched input 'CALL' expecting")
}
test("Test Call Produce with semicolon") {
val call = parser.parsePlan("CALL system.func(c1 => 1, c2 => '2', c3 => true)").asInstanceOf[CallCommand]
assertResult(ImmutableList.of("system", "func"))(JavaConverters.seqAsJavaListConverter(call.name).asJava)
assertResult(3)(call.args.size)
checkArg(call, 0, "c1", 1, DataTypes.IntegerType)
checkArg(call, 1, "c2", "2", DataTypes.StringType)
checkArg(call, 2, "c3", true, DataTypes.BooleanType)
val call2 = parser.parsePlan("CALL system.func2(c1 => 1, c2 => '2', c3 => true);").asInstanceOf[CallCommand]
assertResult(ImmutableList.of("system", "func2"))(JavaConverters.seqAsJavaListConverter(call2.name).asJava)
assertResult(3)(call2.args.size)
checkArg(call2, 0, "c1", 1, DataTypes.IntegerType)
checkArg(call2, 1, "c2", "2", DataTypes.StringType)
checkArg(call2, 2, "c3", true, DataTypes.BooleanType)
}
protected def checkParseExceptionContain(sql: String)(errorMsg: String): Unit = {
var hasException = false
try {