Is it possible to change a column name in Spark SQL in Hive?

Viewed 4206

I'm trying to rename a column (date type), but wasn't sure if the syntax was wrong or if this just isn't possible in Spark SQL:

ALTER TABLE user.temp_medicalclaims 
CHANGE vendor_test_id date_service DATE

brings up this error:

org.apache.spark.sql.AnalysisException: ALTER TABLE CHANGE COLUMN is not supported for changing column 'vendor_test_id' with type 'DateType' to 'date_service' with type 'DateType';

1 Answers

I don't think its still possible with Spark and there is an open SPARK-21823 jira addressing same issue.

  • We still need to use Hive/Beeline to change column names in the table.

(or)

  • Dropping the table and recreating the table with new column names using Spark.
Related