[ 
https://issues.apache.org/jira/browse/IMPALA-8367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16842123#comment-16842123
 ] 

Tamas Mate commented on IMPALA-8367:
------------------------------------

[~tarmstrong], I have checked the Hive behavior, it uses 
[SimpleDateFormat|https://github.com/cloudera/hive/blob/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFFromUnixTime.java#L121]
 to resolve the format and 'u' is the day number of the week. While MySQL 
behaves a bit differently, it goes with NULL if the value is null, otherwise it 
prints the unknown format.
{code:sql}
SELECT FROM_UNIXTIME(NULL, 'u');
+--------------------------+
| FROM_UNIXTIME(NULL, 'u') |
+--------------------------+
| NULL                     |
+--------------------------+

SELECT FROM_UNIXTIME(123, 'u');
+-------------------------+
| FROM_UNIXTIME(123, 'u') |
+-------------------------+
| u                       |
+-------------------------+
{code}
Should we go with the following or should we think about implementing the Hive 
behavior?
 - SELECT FROM_UNIXTIME(NULL, 'u'); -> NULL
 - SELECT FROM_UNIXTIME(123, 'u'); -> Fail the query with "Bad date/time 
conversion format: u"

> from_unixtime Bad date/time conversion format: u on NULL value
> --------------------------------------------------------------
>
>                 Key: IMPALA-8367
>                 URL: https://issues.apache.org/jira/browse/IMPALA-8367
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.11.0
>         Environment: impalad version 2.11.0-cdh5.14.2 RELEASE (build 
> ed85dce709da9557aeb28be89e8044947708876c) Built on Tue Mar 27 13:39:48 PDT 
> 2018
>            Reporter: Sergio Leoni
>            Assignee: Tamas Mate
>            Priority: Minor
>              Labels: newbie, ramp-up
>
> The function
> {code:sql}
>  from_unixtime(bigint unixtime[, string format]) {code}
> output error if the value of unixtime is NULL and format is 'u'.
>  
> This doesn't work:
> {code:sql}
> SELECT FROM_UNIXTIME(NULL, 'u')
> {code}
> {noformat}
> Bad date/time conversion format: u{noformat}
>  
> This works:
> {code:sql}
> SELECT FROM_UNIXTIME(NULL, 'yyyy-MM-dd')
> {code}
> {noformat}
> |from_unixtime(null, 'yyyy-mm-dd')|
> |---------------------------------|
> | NULL                            |
> |---------------------------------|{noformat}
>  
> I haven't checked all the possible combinations.
> Other software like Hive handles this correctly.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to