yaooqinn commented on a change in pull request #29627:
URL: https://github.com/apache/spark/pull/29627#discussion_r482103624
##########
File path:
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
##########
@@ -818,6 +818,7 @@ primaryExpression
constant
: NULL
#nullLiteral
+ | INTERVAL STRING AS? identifier?
#maybeAliasedIntervalLiteral
Review comment:
Before this PR, these cases will be captured by grammar rule
`multiUnitsInterval` but not `typedLiteral`, e.g. for interval '1 day' day, the
value is `1 day` and the unit is day, which actually should be parsed as
`((interval 1 day) as day)`
In this PR, I add a new rule "INTERVAL STRING AS? identifier? " to handle
interval typed literals(maybe aliasing) and 1-stingvalue-unit interval together
and before the rule `multiUnitsInterval`.
when the "AS" key is not null, the `STRING` must be the whole context of the
interval whether it is valid or not, the identifier should be the alias name or
else the "AS" itself as alias name.
when the "AS" key is null
1 and when the `STRING` contains any alphabet, we can assume that the
`STRING` is the whole context of the interval whether it is valid or not. the
identifier part will be alias name if present
2 and when the `STRING` contains no alphabet, e.g. '1' day, '-1' day,
'\t1' day, so the identifier here should be the unit part whether it is valid
or not.
Also updated in PR desc.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]