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

Zoltan Haindrich commented on HIVE-17230:
-----------------------------------------

I've not found any recommendation in the sql standard how this should be 
formatted on outputting it; however here's what I've found:

* psql - displays timestamp precision only on demand (supresses trailing zeros):
{code}
select cast('2011-11-11 11:11:11.123' as timestamp(2)), cast('2011-11-11 
11:11:11' as timestamp(2));
 2011-11-11 11:11:11.12 | 2011-11-11 11:11:11
{code}
* mariadb - seems to be not supporting {{cast}} for me..
  creating a table; and setting timestamp precision explicitly to 2 makes it 
show .00 all the time
  I must note that {{timestamp}} without specifier should be 6 precise
* oracle has a supercomplicated formatter; which by default outputs all 6 
precision digits.
* hive (as of now)
 does not support the timestamp precision setting
 stores all timestamps with precision 9 
 cli: trims trailing zeros

I think from the above that the most user friendly is the behaviour of psql...
I think the only case when we might be ok to show a single trailing zero in 
case of precision 1. - so I think it would be better to remove those lone 
trailing 0s.

{code}
create table t(a timestamp);
insert into t values
('2011-11-11 11:11:11')
,('2011-11-11 11:11:11.1234')
,('2011-11-11 11:11:11.1234567')
,('2011-11-11 11:11:11.123456789')
,('2011-11-11 11:11:11.1234567890123')
,('2011-11-11 11:11:11.12345678901234567890')
,('2011-11-11 11:11:11.12345678901234567890123456')
;
select * from t;
{code}

> Timestamp format different in HiveCLI and Beeline
> -------------------------------------------------
>
>                 Key: HIVE-17230
>                 URL: https://issues.apache.org/jira/browse/HIVE-17230
>             Project: Hive
>          Issue Type: Bug
>          Components: Beeline, CLI
>            Reporter: Peter Vary
>            Assignee: Marta Kuczora
>         Attachments: HIVE-17230.1.patch, HIVE-17230.2.patch, 
> HIVE-17230.3.patch
>
>
> The issue can be reproduced with the following commands:
> {code}
> create table timestamp_test(t timestamp);
> insert into table timestamp_test values('2000-01-01 01:00:00');
> select * from timestamp_test;
> {code}
> The timestamp is displayed without nanoseconds in HiveCLI:
> {code}
> 2000-01-01 01:00:00
> {code}
> When the exact same timestamp is displayed in BeeLine it displays:
> {code}
> 2000-01-01 01:00:00.0
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to