[
https://issues.apache.org/jira/browse/HIVE-24565?focusedWorklogId=527920&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-527920
]
ASF GitHub Bot logged work on HIVE-24565:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 24/Dec/20 01:07
Start Date: 24/Dec/20 01:07
Worklog Time Spent: 10m
Work Description: jcamachor commented on a change in pull request #1810:
URL: https://github.com/apache/hive/pull/1810#discussion_r548335382
##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveLexerParent.g
##########
@@ -373,6 +373,8 @@ KW_COST: 'COST';
KW_JOINCOST: 'JOINCOST';
KW_WITHIN: 'WITHIN';
KW_PKFK_JOIN: 'PKFK_JOIN';
+KW_LEADING: 'LEADING';
Review comment:
Since these two keywords are reserved, can you add a test to
`TestSQL11ReservedKeyWordsNegative.java`?
##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -464,6 +473,7 @@ atomExpression
| whenExpression
| (subQueryExpression)=> (subQueryExpression)
-> ^(TOK_SUBQUERY_EXPR TOK_SUBQUERY_OP subQueryExpression)
+ | (functionName LPAREN (leading=KW_LEADING | trailing=KW_TRAILING |
KW_BOTH)? (trim_characters=selectExpression)? KW_FROM (str=selectExpression)
RPAREN) => trimFunction
Review comment:
I think this would match any function name, that then would be converted
to `trim` (or any other variant) by the rules in `trimFunction`?
I think one way of fixing this could be to declare `TRIM` as a keyword, and
match directly on `TRIM` (TRIM is a reserved keyword in SQL standard) rather
than `functionName`.
Could you also add a negative test, i.e., a test where the trim construct is
correct but the function name is different, and make sure it fails and it is
not transformed by the parser?
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 527920)
Time Spent: 20m (was: 10m)
> Implement standard trim function
> --------------------------------
>
> Key: HIVE-24565
> URL: https://issues.apache.org/jira/browse/HIVE-24565
> Project: Hive
> Issue Type: Improvement
> Components: Parser, UDF
> Reporter: Krisztian Kasa
> Assignee: Krisztian Kasa
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> {code}
> <trim function> ::=
> TRIM <left paren> <trim operands> <right paren>
> <trim operands> ::=
> [ [ <trim specification> ] [ <trim character> ] FROM ] <trim source>
> <trim source> ::=
> <character value expression>
> <trim specification> ::=
> LEADING
> | TRAILING
> | BOTH
> <trim character> ::=
> <character value expression>
> {code}
> Example
> {code}
> SELECT TRIM(LEADING '0' FROM '000123');
> 123
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)