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]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Hive Alter column type

avatar

hello,

I am using hive 1.2.1.

I executed the following command to change the type of a column from timestamp to date

ALTER TABLE table_name CHANGE column_name column_name date CASCADE;

the command was executed successfully.

when i want to retrieve the data from the table using: select * from table_name

I got the following error:

Failed with exception java.io.IOException:org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.ClassCastException: org.apache.hadoop.hive.serde2.io.TimestampWritable cannot be cast to org.apache.hadoop.hive.serde2.io.DateWritable

thanks for help.

1 ACCEPTED SOLUTION

avatar
Master Mentor
@Ahmed Missaoui

It has to do with the dataset in the table. Check if date has proper fields.

Good reference

View solution in original post

2 REPLIES 2

avatar
Master Mentor
@Ahmed Missaoui

It has to do with the dataset in the table. Check if date has proper fields.

Good reference

avatar

Thanks a lot for your help.

Effectively, if the data was stored already with timetamp type and the we change the type, the select will not work and we will have the ClassCastException.

If no data was alreday stored with the timestamp type (all values are null) and then we change the type , the select works fine.