Skip to content

Commit e902842

Browse files
committed
Revert "fix(db2): do not embed inline COMMENT= in CTAS SQL"
This reverts commit c7b003c.
1 parent c7b003c commit e902842

2 files changed

Lines changed: 1 addition & 37 deletions

File tree

sqlmesh/core/engine_adapter/db2.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,17 +432,13 @@ def _create_table(
432432
else:
433433
self.drop_view(table, ignore_if_not_exists=True)
434434

435-
# Do NOT pass table_description here: Db2 does not support inline
436-
# COMMENT= in CREATE TABLE AS ... WITH DATA syntax (SQL0104N).
437-
# The description is applied via a separate COMMENT ON TABLE command
438-
# below (when COMMENT_CREATION_TABLE.is_comment_command_only).
439435
create_exp = self._build_create_table_exp(
440436
table_name_or_schema=table_name_or_schema,
441437
expression=expression,
442438
exists=False,
443439
replace=False,
444440
target_columns_to_types=target_columns_to_types,
445-
table_description=None,
441+
table_description=table_description,
446442
table_kind=table_kind,
447443
**kwargs,
448444
)

tests/core/engine_adapter/test_db2.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -221,38 +221,6 @@ def test_ctas_with_data(adapter: Db2EngineAdapter, mocker: MockerFixture):
221221
assert "_subquery" not in sql_calls[0]
222222

223223

224-
def test_ctas_with_table_description(adapter: Db2EngineAdapter, mocker: MockerFixture):
225-
"""CTAS with table_description must not embed COMMENT= in the CREATE TABLE SQL.
226-
227-
Db2 rejects inline COMMENT= in CTAS (SQL0104N). The description must be
228-
applied via a separate COMMENT ON TABLE statement after the table is created.
229-
"""
230-
mocker.patch.object(adapter, "table_exists", return_value=False)
231-
mocker.patch.object(adapter, "drop_view")
232-
233-
adapter.ctas(
234-
table_name="test_schema.test_table",
235-
query_or_df=parse_one("SELECT id FROM source_table"),
236-
exists=False,
237-
table_description="test table description",
238-
column_descriptions={"id": "test id column description"},
239-
)
240-
241-
sql_calls = to_sql_calls(adapter)
242-
# First call: the CTAS itself — must contain WITH DATA and no inline COMMENT=
243-
assert "CREATE TABLE" in sql_calls[0]
244-
assert "WITH DATA" in sql_calls[0]
245-
assert "COMMENT=" not in sql_calls[0].replace(" ", "")
246-
# Second call: separate COMMENT ON TABLE
247-
assert any("COMMENT ON TABLE" in c for c in sql_calls), (
248-
"Expected a separate COMMENT ON TABLE statement"
249-
)
250-
# Third call: separate COMMENT ON COLUMN
251-
assert any("COMMENT ON COLUMN" in c for c in sql_calls), (
252-
"Expected a separate COMMENT ON COLUMN statement"
253-
)
254-
255-
256224
# ---------------------------------------------------------------------------
257225
# drop_view — guards via SYSCAT.VIEWS (no DROP VIEW IF EXISTS in Db2)
258226
# ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)