@@ -793,11 +793,8 @@ public void testInvalidQuotingAsFromIndexPattern() {
793
793
expectError ("FROM \" foo\" bar\" " , ": token recognition error at: '\" '" );
794
794
expectError ("FROM \" foo\" \" bar\" " , ": extraneous input '\" bar\" ' expecting <EOF>" );
795
795
796
- expectError ("FROM \" \" \" foo\" \" \" bar\" \" \" " , ": mismatched input 'bar' expecting {<EOF>, '|', ',', OPENING_BRACKET, 'metadata'}" );
797
- expectError (
798
- "FROM \" \" \" foo\" \" \" \" \" \" bar\" \" \" " ,
799
- ": mismatched input '\" bar\" ' expecting {<EOF>, '|', ',', OPENING_BRACKET, 'metadata'}"
800
- );
796
+ expectError ("FROM \" \" \" foo\" \" \" bar\" \" \" " , ": mismatched input 'bar' expecting {<EOF>, '|', ',', '[', 'metadata'}" );
797
+ expectError ("FROM \" \" \" foo\" \" \" \" \" \" bar\" \" \" " , ": mismatched input '\" bar\" ' expecting {<EOF>, '|', ',', '[', 'metadata'}" );
801
798
}
802
799
803
800
public void testInvalidQuotingAsMetricsIndexPattern () {
@@ -1087,7 +1084,7 @@ public void testMetadataFieldOnOtherSources() {
1087
1084
expectError ("show info metadata _index" , "line 1:11: token recognition error at: 'm'" );
1088
1085
expectError (
1089
1086
"explain [from foo] metadata _index" ,
1090
- "line 1:20: mismatched input 'metadata' expecting {'|', ',', OPENING_BRACKET , ']', 'metadata'}"
1087
+ "line 1:20: mismatched input 'metadata' expecting {'|', ',', '[' , ']', 'metadata'}"
1091
1088
);
1092
1089
}
1093
1090
@@ -3044,7 +3041,7 @@ public void testNamedFunctionArgumentInInvalidPositions() {
3044
3041
String map = "{\" option1\" :\" string\" , \" option2\" :1}" ;
3045
3042
3046
3043
Map <String , String > commands = Map .ofEntries (
3047
- Map .entry ("from {}" , "line 1:7: mismatched input '\" option1\" ' expecting {<EOF>, '|', ',', OPENING_BRACKET , 'metadata'}" ),
3044
+ Map .entry ("from {}" , "line 1:7: mismatched input '\" option1\" ' expecting {<EOF>, '|', ',', '[' , 'metadata'}" ),
3048
3045
Map .entry ("row x = {}" , "line 1:9: extraneous input '{' expecting {QUOTED_STRING, INTEGER_LITERAL" ),
3049
3046
Map .entry ("eval x = {}" , "line 1:22: extraneous input '{' expecting {QUOTED_STRING, INTEGER_LITERAL" ),
3050
3047
Map .entry ("where x > {}" , "line 1:23: no viable alternative at input 'x > {'" ),
@@ -3951,4 +3948,19 @@ public void testUnclosedParenthesis() {
3951
3948
expectError (q , "Invalid query" );
3952
3949
}
3953
3950
}
3951
+
3952
+ // [ and ( are used to trigger a double mode causing their symbol name (instead of text) to be used in error reporting
3953
+ // this test checks that their are properly replaced in the error message
3954
+ public void testPreserveParanthesis () {
3955
+ // test for (
3956
+ expectError ("row a = 1 not in" , "line 1:17: mismatched input '<EOF>' expecting '('" );
3957
+ expectError ("row a = 1 | where a not in" , "line 1:27: mismatched input '<EOF>' expecting '('" );
3958
+ expectError ("row a = 1 | where a not in (1" , "line 1:30: mismatched input '<EOF>' expecting {',', ')'}" );
3959
+ expectError ("row a = 1 | where a not in [1" , "line 1:28: missing '(' at '['" );
3960
+ expectError ("row a = 1 | where a not in 123" , "line 1:28: missing '(' at '123'" );
3961
+ // test for [
3962
+ expectError ("explain" , "line 1:8: mismatched input '<EOF>' expecting '['" );
3963
+ expectError ("explain ]" , "line 1:9: token recognition error at: ']'" );
3964
+ expectError ("explain [row x = 1" , "line 1:19: missing ']' at '<EOF>'" );
3965
+ }
3954
3966
}
0 commit comments