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?

preguntada hace un año2,9 mil visualizaciones
3 Respuestas
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
respondido hace un año
  • 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.

respondido hace un año
0

none of the suggestions works

respondido hace 7 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas