How can I rename a column on an iceberg table in Athena?

0

When I try to run the following query in Athena:

ALTER TABLE my_iceberg_table ALTER COLUMN old_column_name TO new_column_name

I get the following error:

line 1:37: missing 'TO' at 'COLUMN'

Based on the apache iceberg documentation this should be the correct syntax to rename the column: https://iceberg.apache.org/docs/latest/spark-ddl/#alter-table--rename-column Furthermore when I run the same query through an external Starburst cluster it works, which further suggests that this should be the correct syntax. What is going wrong here?

asked 7 months ago1335 views
2 Answers
0

Hello, you can check this page section "ALTER TABLE CHANGE COLUMN" (Changes the name, type, order or comment of a column).

It looks like it would be:

ALTER TABLE my_iceberg_table CHANGE COLUMN old_column_name new_column_name

AWS
Vincent
answered 7 months ago
  • Thank you for the answer, but unfortunately this still gives me an error: Detail:FAILED: ParseException line 1:128 cannot recognize input near '<EOF>' '<EOF>' '<EOF>' Were you able to do this successfully?

0

https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg-evolving-table-schema.html#querying-iceberg-alter-table-change-column

You need to use CHANGE and include the same type for the rename.

ALTER TABLE <my_iceberg_table> CHANGE <old_column_name> <new_column_name> <current_type>;

I had to do this yesterday, it's dumb but it works.

answered 5 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions