Skip to content

fix(snowflake): use ALTER ICEBERG TABLE to register column comments on Iceberg tables - #6038

Open
sineline wants to merge 1 commit into
SQLMesh:mainfrom
sineline:fix/snowflake-iceberg-column-comments
Open

fix(snowflake): use ALTER ICEBERG TABLE to register column comments on Iceberg tables#6038
sineline wants to merge 1 commit into
SQLMesh:mainfrom
sineline:fix/snowflake-iceberg-column-comments

Conversation

@sineline

@sineline sineline commented Sep 9, 2026

Copy link
Copy Markdown

Follow-up to #5722, related to #5721.

Snowflake rejects ALTER TABLE for Iceberg tables and requires ALTER ICEBERG TABLE instead. SnowflakeEngineAdapter._create_column_comments builds its statement with a hardcoded TABLE kind, so registering column comments on an Iceberg table with a post-creation command emits:

ALTER TABLE "t" ALTER COLUMN "a" COMMENT '...'

The call is wrapped in try/except, so the plan does not fail: the comments are silently dropped and a warning misattributes the failure to limited permissions.

This path is only taken when the comments cannot be inlined into the CTAS schema definition, i.e. when the column types are not fully known. When the types are known, the comments are part of the CREATE ICEBERG TABLE statement and are registered correctly.

Changes

  • EngineAdapter._create_column_comments accepts table_format, mirroring the _create_table convention, and the base adapter passes it from the two table creation paths (create_table and _create_table_from_source_queries).

  • SnowflakeEngineAdapter._create_column_comments derives the Iceberg-specific kind from it, only when the kind is TABLE, so views are unaffected:

    ALTER ICEBERG TABLE "t" ALTER COLUMN "a" COMMENT '...'
  • The MySQL and BigQuery overrides gain the same parameter so their signatures stay compatible with the base class; they do not use it.

Reference: https://docs.snowflake.com/en/sql-reference/sql/alter-iceberg-table#syntax ({ ALTER | MODIFY } [ COLUMN ] <col_name> COMMENT '<string>', comma-separated for multiple columns).

Tests

  • test_column_comments_iceberg: a direct call emits ALTER ICEBERG TABLE ... ALTER COLUMN ... COMMENT ... for multiple columns.
  • test_ctas_column_comments_iceberg: an end-to-end ctas with unknown column types emits CREATE ICEBERG TABLE ... AS SELECT ... followed by the ALTER ICEBERG TABLE comment statement.

The generated DDL is verified at unit level against the documented syntax; it has not been validated against a live Snowflake account.

…n Iceberg tables

Snowflake rejects `ALTER TABLE` for Iceberg tables and requires
`ALTER ICEBERG TABLE` instead. `SnowflakeEngineAdapter._create_column_comments`
builds its statement with a hardcoded `TABLE` kind, so registering column
comments on an Iceberg table with a post-creation command emitted
`ALTER TABLE ... ALTER COLUMN ... COMMENT`. The failure is swallowed and
logged as a permissions warning, so the comments were silently dropped.

This path is only taken when the comments can't be inlined into the CTAS
schema definition, i.e. when the column types are not fully known.

`_create_column_comments` now accepts `table_format`, mirroring the
`_create_table` convention, and the base adapter passes it from the two
table creation paths. The Snowflake adapter derives the Iceberg-specific
table kind from it.

Follow-up to SQLMesh#5722. Related: SQLMesh#5721

Signed-off-by: Guillem G <guillem.gimenez@titanos.tv>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant