support encoding grammar in old planner
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index 8abddcc..5c27604 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -375,6 +375,7 @@ KW_DYNAMIC, KW_ELSE, KW_ENABLE, + KW_ENCODING, KW_ENCRYPTKEY, KW_ENCRYPTKEYS, KW_END, @@ -809,6 +810,8 @@ nonterminal List<TypeDef> type_def_list, type_def_nullable_list; nonterminal FunctionArgsDef func_args_def; nonterminal Type type; +nonterminal ScalarType scalar_type; +nonterminal String opt_encoding; nonterminal Expr cast_expr, case_else_clause, analytic_expr; nonterminal LiteralExpr literal; nonterminal CaseExpr case_expr; @@ -6883,7 +6886,18 @@ {: RESULT = new LimitElement(offset.longValue(), limit.longValue()); :} ; -type ::= +opt_encoding ::= + /* empty */ + {: + RESULT = ""; + :} + | KW_ENCODING STRING_LITERAL:encoding + {: + RESULT = encoding; + :} + ; + +scalar_type ::= KW_TINYINT opt_field_length {: RESULT = Type.TINYINT; :} | KW_SMALLINT opt_field_length @@ -6953,12 +6967,6 @@ {: RESULT = ScalarType.createVarcharType(-1); :} | KW_VARCHAR {: RESULT = ScalarType.createVarcharType(-1); :} - | KW_ARRAY LESSTHAN type:value_type GREATERTHAN - {: RESULT = new ArrayType(value_type); :} - | KW_MAP LESSTHAN type:key_type COMMA type:value_type GREATERTHAN - {: RESULT = new MapType(key_type,value_type); :} - | KW_STRUCT LESSTHAN struct_field_list:fields GREATERTHAN - {: RESULT = new StructType(fields); :} | KW_CHAR LPAREN INTEGER_LITERAL:len RPAREN {: ScalarType type = ScalarType.createCharType(len.intValue()); RESULT = type; @@ -7003,15 +7011,26 @@ {: ScalarType type = ScalarType.createHllType(); RESULT = type; :} + | KW_ALL + {: RESULT = Type.ALL; :} + ; + +type ::= + // ignore encoding in old planner + scalar_type:scalaType opt_encoding:encoding + {: RESULT = scalaType; :} + | KW_ARRAY LESSTHAN type:value_type GREATERTHAN + {: RESULT = new ArrayType(value_type); :} + | KW_MAP LESSTHAN type:key_type COMMA type:value_type GREATERTHAN + {: RESULT = new MapType(key_type,value_type); :} + | KW_STRUCT LESSTHAN struct_field_list:fields GREATERTHAN + {: RESULT = new StructType(fields); :} | KW_AGG_STATE LESSTHAN IDENT:fnName LPAREN type_def_nullable_list:list RPAREN GREATERTHAN {: RESULT = Expr.createAggStateType(fnName, list.stream().map(TypeDef::getType).collect(Collectors.toList()), list.stream().map(TypeDef::getNullable).collect(Collectors.toList())); :} - | KW_ALL - {: RESULT = Type.ALL; :} - ; opt_field_length ::= LPAREN INTEGER_LITERAL:length RPAREN @@ -8548,6 +8567,8 @@ | time_unit:id {: RESULT = id; :} | KW_ENABLE:id + | KW_ENCODING:id + {: RESULT = id; :} {: RESULT = id; :} | KW_FEATURE:id {: RESULT = id; :}
diff --git a/fe/fe-core/src/main/jflex/sql_scanner.flex b/fe/fe-core/src/main/jflex/sql_scanner.flex index 9903675..5a2f594 100644 --- a/fe/fe-core/src/main/jflex/sql_scanner.flex +++ b/fe/fe-core/src/main/jflex/sql_scanner.flex
@@ -215,6 +215,7 @@ keywordMap.put("dynamic", new Integer(SqlParserSymbols.KW_DYNAMIC)); keywordMap.put("else", new Integer(SqlParserSymbols.KW_ELSE)); keywordMap.put("enable", new Integer(SqlParserSymbols.KW_ENABLE)); + keywordMap.put("encoding", new Integer(SqlParserSymbols.KW_ENCODING)); keywordMap.put("encryptkey", new Integer(SqlParserSymbols.KW_ENCRYPTKEY)); keywordMap.put("encryptkeys", new Integer(SqlParserSymbols.KW_ENCRYPTKEYS)); keywordMap.put("end", new Integer(SqlParserSymbols.KW_END));