@@ -22,14 +22,21 @@ import org.apache.spark.SparkFunSuite
2222 * Test various parser errors.
2323 */
2424class 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 = {
2631 val e = intercept[ParseException ](CatalystSqlParser .parsePlan(sql))
2732
2833 // Check position.
2934 assert(e.line.isDefined)
3035 assert(e.line.get === line)
3136 assert(e.startPosition.isDefined)
3237 assert(e.startPosition.get === startPosition)
38+ assert(e.stop.startPosition.isDefined)
39+ assert(e.stop.startPosition.get === stopPosition)
3340
3441 // Check messages.
3542 val error = e.getMessage
@@ -39,26 +46,27 @@ class ErrorParserSuite extends SparkFunSuite {
3946 }
4047
4148 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" , " ----------------^^^" )
4351 }
4452
4553 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" , " ------------^^^" )
4856 }
4957
5058 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 ,
5260 " mismatched input" ,
5361 " ---------------------------^^^" )
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" , " ^^^" )
5563 }
5664
5765 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 ,
5967 " Combination of ORDER BY/SORT BY/DISTRIBUTE BY/CLUSTER BY is not supported" ,
6068 " ^^^" )
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 ,
6270 " EXCEPT ALL is not supported" ,
6371 " ^^^" )
6472 }
0 commit comments