@@ -22,14 +22,21 @@ import org.apache.spark.SparkFunSuite
22
22
* Test various parser errors.
23
23
*/
24
24
class ErrorParserSuite extends SparkFunSuite {
25
- def intercept (sql : String , line : Int , startPosition : Int , messages : String * ): Unit = {
25
+ def intercept (
26
+ sql : String ,
27
+ line : Int ,
28
+ startPosition : Int ,
29
+ stopPosition : Int ,
30
+ messages : String * ): Unit = {
26
31
val e = intercept[ParseException ](CatalystSqlParser .parsePlan(sql))
27
32
28
33
// Check position.
29
34
assert(e.line.isDefined)
30
35
assert(e.line.get === line)
31
36
assert(e.startPosition.isDefined)
32
37
assert(e.startPosition.get === startPosition)
38
+ assert(e.stop.startPosition.isDefined)
39
+ assert(e.stop.startPosition.get === stopPosition)
33
40
34
41
// Check messages.
35
42
val error = e.getMessage
@@ -39,26 +46,27 @@ class ErrorParserSuite extends SparkFunSuite {
39
46
}
40
47
41
48
test(" no viable input" ) {
42
- intercept(" select ((r + 1) " , 1 , 16 , " no viable alternative at input" , " ----------------^^^" )
49
+ intercept(" select ((r + 1) " , 1 , 16 , 16 ,
50
+ " no viable alternative at input" , " ----------------^^^" )
43
51
}
44
52
45
53
test(" extraneous input" ) {
46
- intercept(" select 1 1" , 1 , 9 , " extraneous input '1' expecting" , " ---------^^^" )
47
- intercept(" select *\n from r as q t" , 2 , 12 , " extraneous input" , " ------------^^^" )
54
+ intercept(" select 1 1" , 1 , 9 , 10 , " extraneous input '1' expecting" , " ---------^^^" )
55
+ intercept(" select *\n from r as q t" , 2 , 12 , 13 , " extraneous input" , " ------------^^^" )
48
56
}
49
57
50
58
test(" mismatched input" ) {
51
- intercept(" select * from r order by q from t" , 1 , 27 ,
59
+ intercept(" select * from r order by q from t" , 1 , 27 , 31 ,
52
60
" mismatched input" ,
53
61
" ---------------------------^^^" )
54
- intercept(" select *\n from r\n order by q\n from t" , 4 , 0 , " mismatched input" , " ^^^" )
62
+ intercept(" select *\n from r\n order by q\n from t" , 4 , 0 , 4 , " mismatched input" , " ^^^" )
55
63
}
56
64
57
65
test(" semantic errors" ) {
58
- intercept(" select *\n from r\n order by q\n cluster by q" , 3 , 0 ,
66
+ intercept(" select *\n from r\n order by q\n cluster by q" , 3 , 0 , 11 ,
59
67
" Combination of ORDER BY/SORT BY/DISTRIBUTE BY/CLUSTER BY is not supported" ,
60
68
" ^^^" )
61
- intercept(" select * from r except all select * from t" , 1 , 0 ,
69
+ intercept(" select * from r except all select * from t" , 1 , 0 , 41 ,
62
70
" EXCEPT ALL is not supported" ,
63
71
" ^^^" )
64
72
}
0 commit comments