Skip to content

Instantly share code, notes, and snippets.

@tamtam180
Created February 11, 2012 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamtam180/1797071 to your computer and use it in GitHub Desktop.
Save tamtam180/1797071 to your computer and use it in GitHub Desktop.
hive ticket draft1
----- 手直ししたバージョン -----
summary:
utc_from_timestamp and utc_to_timestamp returns incorrect results.
detail:
how to reproduce:
{noformat}
$ echo "2011-12-25 09:00:00.123456" > /tmp/data5.txt
hive> create table ts1(t1 timestamp);
hive> load data local inpath '/tmp/data5.txt' overwrite into table ts1;
hvie> select t1, from_utc_timestamp(t1, 'JST'), from_utc_timestamp(t1, 'JST') from ts1 limit 1;
{noformat}
The following result is expected:
2011-12-25 09:00:00.123456 2011-12-25 18:00:00.123456 2011-12-25 18:00:00.123456
However, the above query return incorrect result like this:
2011-12-26 03:00:00.492456 2011-12-26 03:00:00.492456 2011-12-26 03:00:00.492456
This is because GenericUDFFromUtcTimestamp.applyOffset() does setTime() improperly.
On evaluating query, timestamp argument always returns the same instance.
GenericUDFFromUtcTimestamp.applyOffset() does setTime() on the instance.
That means it adds all offsets in the query.
attached is the patch which fixes this issue
----- ここまで -----
----- 最初のバージョン -----
summary:
utc_from_timestamp and utc_to_timestamp returns incorrect results.
detail:
utc_from_timestamp and utc_to_timestamp returns incorrect results.
reproduce a bug
1. ready test data:
>cat /tmp/data5.txt
2011-12-25 09:00:00.123456
2. create table and load:
create table ts1(t1 timestamp);
load data local inpath '/tmp/data5.txt' overwrite into table ts1;
3. execute query:
select
t1,
from_utc_timestamp(t1, 'JST'),
t1,
from_utc_timestamp(t1, 'JST')
from ts1
limit 1;
This query should return:
2011-12-25 09:00:00.123456 2011-12-25 18:00:00.123456 2011-12-25 09:00:00.123456 2011-12-25 18:00:00.123456
but its returned:
2011-12-26 03:00:00.492456 2011-12-26 03:00:00.492456 2011-12-26 03:00:00.492456 2011-12-26 03:00:00.492456
It seems to refer to the same Timestamp object for every column. ~
and set a value to same Timestamp object in GenericUDFFromUtcTimestamp.applyOffset method.
I attached the patch.~
Hope this helps.
http://mt.orz.at/archives/HIVE-xxxx.1.patch.txt (チケットに添付する)
-----
@tamtam180
Copy link
Author

ありがとうございます!本当に助かります。
手直ししてみました。&後でブログにまとめます。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment