maybeApplySchemaChanges

fun maybeApplySchemaChanges(table: Table, incomingSchema: Schema, columnTypeChangeBehavior: ColumnTypeChangeBehavior, requireSeparateCommitsForColumnReplace: Boolean = false): SchemaUpdateResult

Compare table's current schema with incomingSchema and apply changes as needed:

  1. Remove columns that are no longer in the incoming schema.

  2. Update column types to a common supertype if they differ.

  3. Mark columns newly optional if changed from required.

  4. Add columns that don't exist in the existing schema.

Return

The updated Schema, after changes have been applied and committed.

Parameters

table

The Iceberg table to update.

incomingSchema

The schema describing incoming data.

columnTypeChangeBehavior

How to handle column type changes.

requireSeparateCommitsForColumnReplace

If true, when replacing a column (deleting and re-adding with the same name but different type), the delete and add operations are committed separately. This is required for some catalogs (like BigLake) that don't support deleting and adding a column with the same name in a single commit, even with different field IDs. Default is false for backward compatibility.