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?

質問済み 8ヶ月前1481ビュー
2回答
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
回答済み 8ヶ月前
  • 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.

回答済み 5ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ