Skip to content

[Spark] Schema evolution fails when promoting 'unknown' type column to primitive type聽#18305

Description

@abjain123

Apache Iceberg version

1.11.0 (latest release)

Query engine

Spark

Please describe the bug 馃悶

Iceberg v3 introduces the unknown data type to gracefully represent columns without physical storage (such as Spark's VOID / all-null columns). However, attempting to lazily evolve an unknown column into a concrete primitive type (e.g., STRING) using Spark SQL's ALTER TABLE ... ALTER COLUMN ... TYPE statement fails during logical plan execution.

TypePromotion.canPromote() in Iceberg currently does not handle promotions from UnknownType to primitive types during schema evolution validation, resulting in an IllegalArgumentException

Steps to Reproduce:

spark.sql("CREATE DATABASE IF NOT EXISTS ds2_standalone.iceberg_v3_qe")
spark.sql("DROP TABLE IF EXISTS ds2_standalone.iceberg_v3_qe.table1")
spark.sql("CREATE TABLE ds2_standalone.iceberg_v3_qe.table1 (id INT, payload VOID) USING ICEBERG TBLPROPERTIES ('format-version'='3')")
spark.sql("INSERT INTO ds2_standalone.iceberg_v3_qe.table1 (id) VALUES (1), (2)")
spark.sql("SELECT payload FROM ds2_standalone.iceberg_v3_qe.table1").show()
spark.sql("ALTER TABLE ds2_standalone.iceberg_v3_qe.table1 ALTER COLUMN payload TYPE STRING") ## Fails here!

Error:
The job crashes during logical plan execution with: java.lang.IllegalArgumentException: Unsupported table change: Cannot change column type: payload: unknown -> string

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions