[ 
https://issues.apache.org/jira/browse/HIVE-24565?focusedWorklogId=531053&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-531053
 ]

ASF GitHub Bot logged work on HIVE-24565:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Jan/21 07:37
            Start Date: 05/Jan/21 07:37
    Worklog Time Spent: 10m 
      Work Description: kasakrisz commented on a change in pull request #1810:
URL: https://github.com/apache/hive/pull/1810#discussion_r551761602



##########
File path: ql/src/test/queries/clientpositive/udf_trim.q
##########
@@ -1,2 +1,20 @@
 DESCRIBE FUNCTION trim;
 DESCRIBE FUNCTION EXTENDED trim;
+
+SELECT '"' || trim('   tech   ') || '"';
+
+SELECT '"' || TRIM(' '  FROM  '   tech   ') || '"';
+
+SELECT '"' || TRIM(LEADING '0' FROM '000123') || '"';
+
+SELECT '"' || TRIM(TRAILING '1' FROM 'Tech1') || '"';
+
+SELECT '"' || TRIM(BOTH '1' FROM '123Tech111') || '"';
+
+SELECT '"' || ltrim('   tech   ') || '"', '"' || rtrim('   tech   ') || '"';
+
+SELECT '"' || lTRIM('0'  FROM  '000123') || '"', '"' || rTRIM('0'  FROM  
'000123') || '"';
+
+SELECT trim('000123', '0');

Review comment:
       `null` cannot be passed as a parameter to `trim`. It works in Postgres 
and Oracle but not supported in Hive.
   The following was executed on master without this patch:
   ```
   select trim(null);
   
    org.apache.hadoop.hive.ql.parse.SemanticException: Line 6:7 Wrong arguments 
'TOK_NULL': trim takes only STRING/CHAR/VARCHAR types. Found VOID
   ```
   
   IMHO we can implement this in a follow-up patch.




----------------------------------------------------------------
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: 531053)
    Time Spent: 40m  (was: 0.5h)

> 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: 40m
>  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)

Reply via email to