1

I've an external table in Hive

Current:
col1 - string
col2 - string
col3 - string
col4 - float
col5 - int

I want to change the date type of col3 to date

Expected:
col1 - string
col2 - string
col3 - date
col4 - float
col5 - int

I tried regular sql command but not useful

alter table table_name modify col3 date;

Error:
Error while compiling statement: FAILED: ParseException line 1:32 cannot recognize input near 'modify' 'col3' 'date' in alter table statement

Requesting assistance here. Thanks in advance.

NewLearner
  • 59
  • 1
  • 8

1 Answers1

1

Correct command is:

alter table table_name change col3 col3 date;

The column change command will only modify Hive's metadata, and will not modify data. Users should make sure the actual data layout of the table/partition conforms with the metadata definition.

See syntax and manual here: Change Column Name/Type/Position/Comment

leftjoin
  • 36,950
  • 8
  • 57
  • 116