You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/07/07 20:28:34 UTC

[GitHub] [iceberg] fcomuniz opened a new issue #2791: Alter table to generic types

fcomuniz opened a new issue #2791:
URL: https://github.com/apache/iceberg/issues/2791


   Hi, this project is very awesome, we are starting to use it now for saving our data using iceberg and it is working very well.
   
   One issue we have encountered is when we want to change the data type from an int to a string, just so we can have a more generic data type to store the given information. This happens when there is a schema change from the source and we don't want to lose the data that was in that column.
   
   For example, from spark-sql
   ```
   create table iceberg.bronze.test__test (id int) using iceberg;
   alter table iceberg.bronze.test__test alter column id type string;
   ```
   
   Gives the following error 
   ```
           at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
   Caused by: java.lang.IllegalArgumentException: Cannot change column type: id: long -> string
           at org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:459)
           at org.apache.iceberg.SchemaUpdate.updateColumn(SchemaUpdate.java:244)
           at org.apache.iceberg.spark.Spark3Util.applySchemaChanges(Spark3Util.java:160)
           at org.apache.iceberg.spark.SparkCatalog.commitChanges(SparkCatalog.java:432)
           at org.apache.iceberg.spark.SparkCatalog.alterTable(SparkCatalog.java:216)
           at org.apache.iceberg.spark.SparkCatalog.alterTable(SparkCatalog.java:79)
           at org.apache.spark.sql.execution.datasources.v2.AlterTableExec.run(AlterTableExec.scala:37)
           ... 44 more
   ```
   
   I would just like some pointers as to how i could change the data type of the data, and an idea as to how it could be implemented into the alter table statement.
   
   Thanks for any help you can give.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org