[
https://issues.apache.org/jira/browse/IMPALA-8367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16860609#comment-16860609
]
Gabor Kaszab commented on IMPALA-8367:
--------------------------------------
I tend to disagree here. How likely is it that the user wants to run a query
with a malformed datetime format pattern that actually is not evaluated later
on (e.g. because there are no rows.)? I feel that a malformed format pattern
should be treated as a malformed query.
What if for example the user queries a number of columns where one of them is a
string that is converted to timestamp using a malformed format and this column
contains 1 million Null values and a single not Null? In this case your
proposal would start spitting out rows where this column is Null and then throw
an error when it finds that non-Null value that seems odd to me. Not throwing
an error and returning Null instead for that value would be more dangerous
because we won't be able to differentiate between actual Null values and
"unable to parse" Null values.
Returning an error while the format is being parsed seems the cleanest solution
for me even if there are no rows in that table. This way a very specific error
message can be shown to the user to fix it's malformed format (at least this is
what I'm doing with IMPALA-4018).
Let's say a user writes a query that contains a malformed datetime format but
it doesn't return an error during tokeninzation and there are no rows in that
column so no issue is observed with that query. Later on someone populates that
column as well and the very same query starts failing due to some unknown
datetime pattern element (such as 'u' here) so the user might get confused why
this succeeded before in case that pattern element is not supported at all.
What do you think?
> 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
> 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]