Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 06-15-2019 05:38 PM
Hi,
Data is in files in the following format 2019-06-15T15:43:12 ( yyyy-MM-ddThh:mm:ss )
When I do a select * on the table , it is displayed as NULL
Hive version - 1.2.1
ALTER TABLE table SET SERDEPROPERTIES ("timestamp.formats"="yyyy-MM-dd'T'HH:mm:ss"); - did not help
Followed the links,
https://issues.apache.org/jira/browse/HIVE-9298
https://www.ericlin.me/2017/03/alternative-timestamp-support-in-hive-iso-8601/
Could you please help on this. Thanks
Created 06-16-2019 11:02 PM
ALTER TABLE table SET SERDEPROPERTIES ("timestamp.formats"="yyyy-MM-dd'T'HH:mm:ss");
Works only in case of Textformat,CSV format tables.
If you are having other format table like orc..etc then set serde properties are not got to be working.
-
Tested by creating text format table:
Data:
1,2019-06-15T15:43:12 2,2019-06-15T15:43:19
create table i(id int,ts timestamp) row format delimited fields terminated by ',' stored as textfile;
ALTER TABLE i SET SERDEPROPERTIES ("timestamp.formats"="yyyy-MM-dd'T'HH:mm:ss");
select * from i;
1 2019-06-15 15:43:12
2 2019-06-15 15:43:19-
incase if we have orc file with 2019-06-15T15:43:12 format then altering the serde properties still results null format for timestamp field.
Created 06-16-2019 11:02 PM
ALTER TABLE table SET SERDEPROPERTIES ("timestamp.formats"="yyyy-MM-dd'T'HH:mm:ss");
Works only in case of Textformat,CSV format tables.
If you are having other format table like orc..etc then set serde properties are not got to be working.
-
Tested by creating text format table:
Data:
1,2019-06-15T15:43:12 2,2019-06-15T15:43:19
create table i(id int,ts timestamp) row format delimited fields terminated by ',' stored as textfile;
ALTER TABLE i SET SERDEPROPERTIES ("timestamp.formats"="yyyy-MM-dd'T'HH:mm:ss");
select * from i;
1 2019-06-15 15:43:12
2 2019-06-15 15:43:19-
incase if we have orc file with 2019-06-15T15:43:12 format then altering the serde properties still results null format for timestamp field.
Created 06-19-2019 01:00 AM
Hive Timestamp type accepts format as yyyy-MM-dd HH:mm:ss[.SSS]
hive> select timestamp("2019-06-15 15:43:12");
2019-06-15 15:43:12
hive> select timestamp("2019-06-15 15:43:12.988");
2019-06-15 15:43:12.988hive> select timestamp("2019-06-15T15:43:12")
NULLIf you are thinking to have timestamp type rather than text format tables then you use from_unixtime,unix_timestamp functions to remove "T" from the data and then you can have timestamp type in all formats.
-
If the answer is helpful to resolve the issue, Login and Click on Accept button below to close this thread.This will help other community users to find answers quickly 🙂
Created 06-18-2019 06:43 PM
@Shu: Thank you. Could you please let us know, If we are using file format other than Textformat, CSV, how to handle null for timestamp filed?