You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by "Long, Andrew" <lo...@amazon.com> on 2016/06/30 23:31:30 UTC

Possible Bug: to_date("2015-01-15") returns a string

Hello Everyone,

I ran into this unusual behavior while converting a date string into a date.  I was surprised to find out that to_date will occasionally return a string.

Does this make sense?

Cheers Andrew



hive> CREATE TEMPORARY TABLE datebug
    > AS SELECT to_date("2015-01-10");
Query ID = hadoop_20160630232727_15668184-3af0-4221-a794-9b2a94d4740e
Total jobs = 1
Launching Job 1 out of 1
Tez session was closed. Reopening...
Session re-established.


Status: Running (Executing on YARN cluster with App id application_1467163153575_0039)

--------------------------------------------------------------------------------
        VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
--------------------------------------------------------------------------------
Map 1 ..........   SUCCEEDED      1          1        0        0       0       0
--------------------------------------------------------------------------------
VERTICES: 01/01  [==========================>>] 100%  ELAPSED TIME: 5.77 s
--------------------------------------------------------------------------------
Moving data to: hdfs://ip-172-31-1-35.ec2.internal:8020/tmp/hive/hadoop/a1f9f4d0-36ed-419f-bec3-9b286a7c1201/_tmp_space.db/9c51562e-f8a1-4de8-93a5-f3e874368f43
Table default.datebug stats: [numFiles=1, numRows=1, totalSize=11, rawDataSize=10]
OK
Time taken: 11.968 seconds
hive> describe datebug;
OK
_c0                    string
Time taken: 0.004 seconds, Fetched: 1 row(s)
hive>


Re: Possible Bug: to_date("2015-01-15") returns a string

Posted by Gopal Vijayaraghavan <go...@apache.org>.
> I ran into this unusual behavior while converting a date string into a
>date.

If you're on Hive-1.x, this couldn't be fixed due to backwards compatible
requirements.

If I remember correctly, to_date() pre-dates the Date type in Hive.

Marked incompatible for backport -
<https://issues.apache.org/jira/browse/HIVE-13248>


Cheers,
Gopal





RE: Possible Bug: to_date("2015-01-15") returns a string

Posted by Ryan Harris <Ry...@zionsbancorp.com>.
FWIW, the wiki states that the function returns a string
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDFhttps://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

From: Long, Andrew [loandrew@amazon.com]
Sent: Thursday, June 30, 2016 5:31 PM
To: user@hive.apache.org
Subject: Possible Bug: to_date("2015-01-15") returns a string

Hello Everyone,

I ran into this unusual behavior while converting a date string into a date.  I was surprised to find out that to_date will occasionally return a string.

Does this make sense?

Cheers Andrew



hive> CREATE TEMPORARY TABLE datebug
    > AS SELECT to_date("2015-01-10");
Query ID = hadoop_20160630232727_15668184-3af0-4221-a794-9b2a94d4740e
Total jobs = 1
Launching Job 1 out of 1
Tez session was closed. Reopening...
Session re-established.


Status: Running (Executing on YARN cluster with App id application_1467163153575_0039)

--------------------------------------------------------------------------------
        VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
--------------------------------------------------------------------------------
Map 1 ..........   SUCCEEDED      1          1        0        0       0       0
--------------------------------------------------------------------------------
VERTICES: 01/01  [==========================>>] 100%  ELAPSED TIME: 5.77 s
--------------------------------------------------------------------------------
Moving data to: hdfs://ip-172-31-1-35.ec2.internal:8020/tmp/hive/hadoop/a1f9f4d0-36ed-419f-bec3-9b286a7c1201/_tmp_space.db/9c51562e-f8a1-4de8-93a5-f3e874368f43
Table default.datebug stats: [numFiles=1, numRows=1, totalSize=11, rawDataSize=10]
OK
Time taken: 11.968 seconds
hive> describe datebug;
OK
_c0                    string
Time taken: 0.004 seconds, Fetched: 1 row(s)
hive>

======================================================================
THIS ELECTRONIC MESSAGE, INCLUDING ANY ACCOMPANYING DOCUMENTS, IS CONFIDENTIAL and may contain information that is privileged and exempt from disclosure under applicable law. If you are neither the intended recipient nor responsible for delivering the message to the intended recipient, please note that any dissemination, distribution, copying or the taking of any action in reliance upon the message is strictly prohibited. If you have received this communication in error, please notify the sender immediately.  Thank you.