[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:
@@ -42,7 +42,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
singleStatement
|
singleStatement
|
||||||
: statement EOF
|
: statement ';'* EOF
|
||||||
;
|
;
|
||||||
|
|
||||||
statement
|
statement
|
||||||
|
|||||||
@@ -85,6 +85,26 @@ class TestCallCommandParser extends HoodieSparkSqlTestBase {
|
|||||||
checkParseExceptionContain("CALL cat.system radish kebab")("mismatched input 'CALL' expecting")
|
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 = {
|
protected def checkParseExceptionContain(sql: String)(errorMsg: String): Unit = {
|
||||||
var hasException = false
|
var hasException = false
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user