diff --git a/tests/functional/adapter/test_docs.py b/tests/functional/adapter/test_docs.py index 663d3027..2b017717 100644 --- a/tests/functional/adapter/test_docs.py +++ b/tests/functional/adapter/test_docs.py @@ -15,6 +15,17 @@ select 1 as id """ +iceberg_model_sql = """ +{{ + config( + materialized="table", + table_type="iceberg", + post_hook="alter table model drop column to_drop" + ) +}} +select 1 as id, 'to_drop' as to_drop +""" + override_macros_sql = """ {% macro get_catalog_relations(information_schema, relations) %} {{ return(adapter.get_catalog_by_relations(information_schema, relations)) }} @@ -44,7 +55,6 @@ def custom_verify_catalog_athena(project, expected_catalog, start_time): assert node_key in found_node # the value of found_node[node_key] is not exactly expected_node[node_key] - class TestDocsGenerate(BaseDocsGenerate): """ Override of BaseDocsGenerate to make it working with Athena @@ -88,10 +98,7 @@ def models(self): def macros(self): return {"override_macros_sql.sql": override_macros_sql} - def test_generate_docs( - self, - project, - ): + def test_generate_docs(self, project): results = run_dbt(["run"]) assert len(results) == 1 @@ -99,3 +106,29 @@ def test_generate_docs( assert len(docs_generate._compile_results.results) == 1 assert docs_generate._compile_results.results[0].status == RunStatus.Success assert docs_generate.errors is None + + +class TestDocsGenerateIcebergNonCurrentColumn: + @pytest.fixture(scope="class") + def models(self): + return {"model.sql": iceberg_model_sql} + + @pytest.fixture(scope="class") + def macros(self): + return {"override_macros_sql.sql": override_macros_sql} + + def test_generate_docs(self, project): + results = run_dbt(["run"]) + assert len(results) == 1 + + docs_generate = run_dbt(["--warn-error", "docs", "generate"]) + assert len(docs_generate._compile_results.results) == 1 + assert docs_generate._compile_results.results[0].status == RunStatus.Success + assert docs_generate.errors is None + + catalog_path = os.path.join(project.project_root, "target", "catalog.json") + assert os.path.exists(catalog_path) + catalog = get_artifact(catalog_path) + columns = catalog["nodes"]["model.test.model"]["columns"] + assert "to_drop" not in columns + assert "id" in columns