[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15006904#comment-15006904 ] Ryan Blue commented on HIVE-12196: -- Thanks for fixign this, Aihua! > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Fix For: 1.3.0, 2.0.0 > > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15006814#comment-15006814 ] Aihua Xu commented on HIVE-12196: - Committed to branch-1 as well. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Fix For: 2.0.0 > > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15006799#comment-15006799 ] Aihua Xu commented on HIVE-12196: - Committed to master branch. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Fix For: 2.0.0 > > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14997228#comment-14997228 ] Chaoyu Tang commented on HIVE-12196: Patch looks good to me. +1. Actually I think in the second case, TIMESTAMP '2015-04-11-12:24:34.535' is a timestamp literal where the literal provided here for ts was not in correct format. Kind of syntax error. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14993745#comment-14993745 ] Aihua Xu commented on HIVE-12196: - I'm looking into that. Seems we would be able to throw exception for the first case as the second one during the compilation time as well. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14993798#comment-14993798 ] Aihua Xu commented on HIVE-12196: - Actually the second query throwing the exception is a special case, that is, for timestamp function, we will directly call Timestamp class to convert and throw exception if it's invalid. For other functions like cast(), unix_timestamp(), to_date(), etc (even equivalent timestamp() ) they all behave the same which will return NULL. We can't do to throw exception in GenericUDFFromUtcTimestamp.evaluate() if the format is incorrect since it will be used during runtime as well. We don't want to fail the whole query as you pointed above. So {{select TIMESTAMP '2015-04-11-12:24:34.535'; }} throws exception while {{select TIMESTAMP('2015-04-11-12:24:34.535');}} returns null. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14987922#comment-14987922 ] Aihua Xu commented on HIVE-12196: - [~rdblue] This behavior actually matches most of the conversion functions. e.g., cast('abc' as int) or date('abc') will return NULL rather than throwing an exception. It's from the runtime execution. The second one actually throws the exception during the compile time which converts the constant string to timestamp, which also seems to makes sense. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14987858#comment-14987858 ] Aihua Xu commented on HIVE-12196: - Simple fix which will check the value after the conversion. If it's null, return null. So if the timestamp is not correct, it will generate a null value. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14987860#comment-14987860 ] Ryan Blue commented on HIVE-12196: -- [~aihuaxu], this doesn't look like the correct behavior. While it is great to not throw the NPE, I don't see why the first query shouldn't also throw a SemanticException about the invalid timestamp value. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (HIVE-12196) NPE when converting bad timestamp value
[ https://issues.apache.org/jira/browse/HIVE-12196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=14988136#comment-14988136 ] Ryan Blue commented on HIVE-12196: -- Thanks, it sounds like there are actually two problems. First, the one that you fixed which is causing the NPE. Second, whether this behavior should be caught and result in an exception or NULL. I don't see why it shouldn't be the case that the timestamp in the first query isn't converted in the compiler but the second is. I guess it could be that the type information for that function isn't available, so the coercion actually takes place at runtime when you don't want to fail an entire query for a single value (even if it is a literal value in this case). I think that could be fixed, but I also have no idea how much work it would be so I'll defer to someone with more Hive knowledge. > NPE when converting bad timestamp value > --- > > Key: HIVE-12196 > URL: https://issues.apache.org/jira/browse/HIVE-12196 > Project: Hive > Issue Type: Sub-task > Components: Hive >Affects Versions: 1.1.1 >Reporter: Ryan Blue >Assignee: Aihua Xu > Attachments: HIVE-12196.patch > > > When I convert a timestamp value that is slightly wrong, the result is a NPE. > Other queries correctly reject the timestamp: > {code} > hive> select from_utc_timestamp('2015-04-11-12:24:34.535', 'UTC'); > FAILED: NullPointerException null > hive> select TIMESTAMP '2015-04-11-12:24:34.535'; > FAILED: SemanticException Unable to convert time literal > '2015-04-11-12:24:34.535' to time value. > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)