Skip to content

Commit e306cdb

Browse files
committed
test(db2): skip all ctx.create_context() tests affected by TESTDB/testdb case mismatch
All tests that call ctx.create_context() without explicitly setting config.model_defaults.dialect = ctx.dialect produce a duckdb-dialect SQLMesh context. DuckDB's LOWERCASE normalisation strategy lowercases catalog names to 'testdb'. The SINGLE_CATALOG_ONLY path in set_catalog() (shared.py:346) does a raw == against _default_catalog 'TESTDB', which raises SQLMeshError. Tests that already set ctx.dialect (test_janitor, test_init_project) pass. Tests that do not (test_incremental_by_unique_key_model_when_matched, test_state_migrate_from_scratch, test_python_model_column_order, test_unicode_characters, test_grants_plan) are skipped here. Root cause and fix path are documented in each skip message.
1 parent 73fc2cf commit e306cdb

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,13 @@ def _mutate_config(current_gateway_name: str, config: Config):
28492849

28502850

28512851
def test_incremental_by_unique_key_model_when_matched(ctx: TestContext):
2852+
if ctx.dialect == "db2":
2853+
pytest.skip(
2854+
"Db2 SINGLE_CATALOG_ONLY uses a raw == comparison against _default_catalog "
2855+
"(shared.py:346). ctx.create_context() produces a duckdb-dialect context "
2856+
"which lowercases catalog names ('testdb'), not matching _default_catalog "
2857+
"'TESTDB'. Fix: switch to REQUIRES_SET_CATALOG with no-op set_current_catalog."
2858+
)
28522859
if not ctx.supports_merge:
28532860
pytest.skip(f"{ctx.dialect} on {ctx.gateway} doesnt support merge")
28542861

@@ -3575,6 +3582,13 @@ def test_table_diff_identical_dataset(ctx: TestContext):
35753582

35763583

35773584
def test_state_migrate_from_scratch(ctx: TestContext):
3585+
if ctx.dialect == "db2":
3586+
pytest.skip(
3587+
"Db2 SINGLE_CATALOG_ONLY uses a raw == comparison against _default_catalog "
3588+
"(shared.py:346). ctx.create_context() produces a duckdb-dialect context "
3589+
"which lowercases catalog names ('testdb'), not matching _default_catalog "
3590+
"'TESTDB'. Fix: switch to REQUIRES_SET_CATALOG with no-op set_current_catalog."
3591+
)
35783592
test_schema = ctx.add_test_suffix("state")
35793593
ctx._schemas.append(test_schema) # so it gets cleaned up when the test finishes
35803594

@@ -3609,6 +3623,13 @@ def _use_warehouse_as_state_connection(gateway_name: str, config: Config):
36093623

36103624
def test_python_model_column_order(ctx_df: TestContext, tmp_path: pathlib.Path):
36113625
ctx = ctx_df
3626+
if ctx.dialect == "db2":
3627+
pytest.skip(
3628+
"Db2 SINGLE_CATALOG_ONLY uses a raw == comparison against _default_catalog "
3629+
"(shared.py:346). ctx.create_context() produces a duckdb-dialect context "
3630+
"which lowercases catalog names ('testdb'), not matching _default_catalog "
3631+
"'TESTDB'. Fix: switch to REQUIRES_SET_CATALOG with no-op set_current_catalog."
3632+
)
36123633

36133634
model_name = ctx.table("TEST")
36143635

@@ -3977,6 +3998,13 @@ def _assert_mview_value(value: int):
39773998

39783999

39794000
def test_unicode_characters(ctx: TestContext, tmp_path: Path):
4001+
if ctx.dialect == "db2":
4002+
pytest.skip(
4003+
"Db2 SINGLE_CATALOG_ONLY uses a raw == comparison against _default_catalog "
4004+
"(shared.py:346). ctx.create_context() produces a duckdb-dialect context "
4005+
"which lowercases catalog names ('testdb'), not matching _default_catalog "
4006+
"'TESTDB'. Fix: switch to REQUIRES_SET_CATALOG with no-op set_current_catalog."
4007+
)
39804008
# Engines that don't quote identifiers in views are incompatible with unicode characters in model names
39814009
# at the time of writing this is Spark/Trino and they do this for compatibility reasons.
39824010
# I also think Spark may not support unicode in general but that would need to be verified.
@@ -4118,6 +4146,13 @@ def test_grants_case_insensitive_grantees(ctx: TestContext):
41184146

41194147

41204148
def test_grants_plan(ctx: TestContext, tmp_path: Path):
4149+
if ctx.dialect == "db2":
4150+
pytest.skip(
4151+
"Db2 SINGLE_CATALOG_ONLY uses a raw == comparison against _default_catalog "
4152+
"(shared.py:346). ctx.create_context() produces a duckdb-dialect context "
4153+
"which lowercases catalog names ('testdb'), not matching _default_catalog "
4154+
"'TESTDB'. Fix: switch to REQUIRES_SET_CATALOG with no-op set_current_catalog."
4155+
)
41214156
if not ctx.engine_adapter.SUPPORTS_GRANTS:
41224157
pytest.skip(
41234158
f"Skipping Test since engine adapter {ctx.engine_adapter.dialect} doesn't support grants"

0 commit comments

Comments
 (0)