[#7171] Support parsing SQL Server CONVERT() function
This commit is contained in:
parent
98155190d8
commit
79821229e2
@ -533,25 +533,26 @@ term =
|
||||
| 'ARRAY' '[' [ fields ] ']'
|
||||
| 'AVG' '(' [ 'DISTINCT' | 'ALL' ] field ')' [ keep | filter ] [ over ]
|
||||
| 'BIT_LENGTH' '(' field ')'
|
||||
| 'CONCAT' '(' fields ')'
|
||||
| 'CURRENT_SCHEMA'
|
||||
| 'CURRENT_USER'
|
||||
| 'CHARINDEX' '(' field ',' field ')'
|
||||
| 'CHAR_LENGTH' '(' field ')'
|
||||
| ( 'CEIL' | 'CEILING' ) '(' sum ')'
|
||||
| 'COSH' '(' sum ')'
|
||||
| 'COS' '(' sum ')'
|
||||
| 'COTH' '(' sum ')'
|
||||
| 'COT' '(' sum ')'
|
||||
| 'COUNT' '(' ( '*' | [ 'DISTINCT' | 'ALL' ] field ) ')' [ keep | filter ] [ over ]
|
||||
| 'CURRVAL' '(' ( name | stringLiteral ) ')'
|
||||
| 'CURRENT_TIMESTAMP'
|
||||
| 'CURRENT_TIME'
|
||||
| 'CURRENT_DATE'
|
||||
| case
|
||||
| 'CAST' '(' field 'AS' dataType ')'
|
||||
| 'CONVERT' '(' dataType ',' field ')'
|
||||
| ( 'CEIL' | 'CEILING' ) '(' sum ')'
|
||||
| 'CHARINDEX' '(' field ',' field ')'
|
||||
| 'CHAR_LENGTH' '(' field ')'
|
||||
| 'COALESCE' '(' fields ')'
|
||||
| 'CONCAT' '(' fields ')'
|
||||
| 'COS' '(' sum ')'
|
||||
| 'COSH' '(' sum ')'
|
||||
| 'COT' '(' sum ')'
|
||||
| 'COTH' '(' sum ')'
|
||||
| 'COUNT' '(' ( '*' | [ 'DISTINCT' | 'ALL' ] field ) ')' [ keep | filter ] [ over ]
|
||||
| 'CUME_DIST' ( '(' ')' over | '(' fields ')' withinGroup )
|
||||
| 'CURRVAL' '(' ( name | stringLiteral ) ')'
|
||||
| 'CURRENT_DATE'
|
||||
| 'CURRENT_SCHEMA'
|
||||
| 'CURRENT_TIME'
|
||||
| 'CURRENT_TIMESTAMP'
|
||||
| 'CURRENT_USER'
|
||||
| dateLiteral
|
||||
| 'DATE_TRUNC' '(' stringLiteral ',' field ')'
|
||||
| 'DAY' '(' field ')'
|
||||
@ -647,6 +648,7 @@ term =
|
||||
| 'TANH' '(' sum ')'
|
||||
| timeLiteral
|
||||
| timestampLiteral
|
||||
| 'TO_NUMBER' '(' field ')'
|
||||
| 'TRANSLATE' '(' field ',' field ',' field ')'
|
||||
| 'TRIM' '(' field ')'
|
||||
| 'TRUNC' '(' field ',' stringLiteral ')'
|
||||
|
||||
@ -3810,12 +3810,14 @@ final class ParserImpl implements Parser {
|
||||
|
||||
if ((field = parseFieldCaseIf(ctx)) != null)
|
||||
return field;
|
||||
else if ((field = parseCastIf(ctx)) != null)
|
||||
else if ((field = parseFieldCastIf(ctx)) != null)
|
||||
return field;
|
||||
else if ((field = parseFieldCoalesceIf(ctx)) != null)
|
||||
return field;
|
||||
else if ((field = parseFieldCumeDistIf(ctx)) != null)
|
||||
return field;
|
||||
else if ((field = parseFieldConvertIf(ctx)) != null)
|
||||
return field;
|
||||
|
||||
break;
|
||||
|
||||
@ -5171,7 +5173,7 @@ final class ParserImpl implements Parser {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Field<?> parseCastIf(ParserContext ctx) {
|
||||
private static final Field<?> parseFieldCastIf(ParserContext ctx) {
|
||||
if (parseFunctionNameIf(ctx, "CAST")) {
|
||||
parse(ctx, '(');
|
||||
Field<?> field = parseField(ctx);
|
||||
@ -5185,6 +5187,20 @@ final class ParserImpl implements Parser {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Field<?> parseFieldConvertIf(ParserContext ctx) {
|
||||
if (parseFunctionNameIf(ctx, "CONVERT")) {
|
||||
parse(ctx, '(');
|
||||
DataType<?> type = parseDataType(ctx);
|
||||
parse(ctx, ',');
|
||||
Field<?> field = parseField(ctx);
|
||||
parse(ctx, ')');
|
||||
|
||||
return cast(field, type);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Field<Boolean> parseBooleanValueExpressionIf(ParserContext ctx) {
|
||||
TruthValue truth = parseTruthValueIf(ctx);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user