File tree Expand file tree Collapse file tree
fe-core/src/test/java/com/starrocks/sql/parser
fe-grammar/src/main/antlr/com/starrocks/grammar Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,6 +190,27 @@ void testNonReservedWords_2() {
190190 }
191191 }
192192
193+ @ Test
194+ void testVariantAsIdentifier () {
195+ // VARIANT was added as a baseType keyword; it must remain usable as an identifier
196+ // (bare and backticked) — e.g. as a column name or struct field name.
197+ SessionVariable sessionVariable = new SessionVariable ();
198+ List <String > sqls = Lists .newArrayList (
199+ "select variant from t" ,
200+ "select `variant` from t" ,
201+ "select t.variant from t" ,
202+ "select t.`variant` from t" ,
203+ "select cast(c as struct<variant int, other varchar(10)>) from t" ,
204+ "select cast(c as struct<`variant` int, other varchar(10)>) from t" );
205+ for (String sql : sqls ) {
206+ try {
207+ SqlParser .parse (sql , sessionVariable ).get (0 );
208+ } catch (Exception e ) {
209+ fail ("sql should succeed: " + sql + " errMsg: " + e .getMessage ());
210+ }
211+ }
212+ }
213+
193214 @ Test
194215 void testParseLargeDecimal () {
195216 String sql = "select cast(1 as decimal(85,0))" ;
Original file line number Diff line number Diff line change @@ -3292,7 +3292,7 @@ nonReserved
32923292 | TRIM_SPACE
32933293 | TRIGGERS | TRUNCATE | TYPE | TYPES
32943294 | UNBOUNDED | UNCOMMITTED | UNSET | UNINSTALL | USAGE | USER | USERS | UNLOCK
3295- | VALUE | VARBINARY | VARIABLES | VIEW | VIEWS | VERBOSE | VERSION | VOLUME | VOLUMES
3295+ | VALUE | VARBINARY | VARIABLES | VARIANT | VIEW | VIEWS | VERBOSE | VERSION | VOLUME | VOLUMES
32963296 | WARNINGS | WEEK | WHITELIST | WORK | WRITE | WAREHOUSE | WAREHOUSES
32973297 | YEAR
32983298 | DOTDOTDOT | NGRAMBF | VECTOR
You can’t perform that action at this time.
0 commit comments