Jelly
Jelly

Reputation: 1296

Replace hive table with partition

There is a Hive-table with 2 string columns one partition "cmd_out".

I'm trying to rename all 2 columns ('col1', 'col2'), by using Replace-function:

Alter table 'table_test' replace columns(
  'col22' String,
  'coll33' String
)

But I receive the following exception:

 Partition column name 'cmd_out' conflicts with table columns.

When I include the partition column in query

Alter table 'table_test' replace columns(
  'cmd_out' String,
  'col22' String,
  'coll33' String
)

I receive:

Duplicate column name cmd_out in the table definition

Upvotes: 0

Views: 49

Answers (1)

Koushik Roy
Koushik Roy

Reputation: 7387

if you want to rename a column, you need to use alter table ... change.
Here is the syntax

alter table mytab change col1 new_col1 string;

Upvotes: 1

Related Questions