From 04d01af7567500c26495b1f1aab3f8c246aeb0ce Mon Sep 17 00:00:00 2001 From: Mike Alfare <13974384+mikealfare@users.noreply.github.com> Date: Wed, 11 Oct 2023 13:05:36 -0400 Subject: [PATCH] ADAP-894: Support test results as views (#889) * implement tests for persist test results functionality * updated project config for tests * revert config changes * skip Spark, which needs different delete sql * add Spark config * add a skip marker indicating the issue that needs to be resolved * pull the test case in from core to show that everything passes except for the deletion step * update changelog and test names to reflect renamed parameter * correct fixture names in test * updated the name of the overridden test so that it actually overrides the test * update the row count method so support spark requirements * added --store-failures parameter to the dbt invocation * implement store-failures-as tests * skip spark-session from store-failures-as tests * revert dev requirements to point back to main on dbt-core * revert dev requirements to point back to main on dbt-core * update signature of get_catalog to match dbt-core and appease mypy --- .../unreleased/Features-20230921-180958.yaml | 6 ++++ Makefile | 1 + dbt/adapters/spark/impl.py | 4 ++- .../test_store_test_failures.py | 31 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Features-20230921-180958.yaml rename tests/functional/adapter/{store_test_failures_tests => }/test_store_test_failures.py (62%) diff --git a/.changes/unreleased/Features-20230921-180958.yaml b/.changes/unreleased/Features-20230921-180958.yaml new file mode 100644 index 000000000..66141eb5f --- /dev/null +++ b/.changes/unreleased/Features-20230921-180958.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Support storing test failures as views +time: 2023-09-21T18:09:58.174136-04:00 +custom: + Author: mikealfare + Issue: "6914" diff --git a/Makefile b/Makefile index 876440a01..cc1d9f75d 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ dev: ## Installs adapter in develop mode along with development dependencies dev-uninstall: ## Uninstalls all packages while maintaining the virtual environment ## Useful when updating versions, or if you accidentally installed into the system interpreter pip freeze | grep -v "^-e" | cut -d "@" -f1 | xargs pip uninstall -y + pip uninstall -y dbt-spark .PHONY: mypy mypy: ## Runs mypy against staged changes for static type checking. diff --git a/dbt/adapters/spark/impl.py b/dbt/adapters/spark/impl.py index 2864c4f30..feae34129 100644 --- a/dbt/adapters/spark/impl.py +++ b/dbt/adapters/spark/impl.py @@ -347,7 +347,9 @@ def _get_columns_for_catalog(self, relation: BaseRelation) -> Iterable[Dict[str, as_dict["table_database"] = None yield as_dict - def get_catalog(self, manifest: Manifest) -> Tuple[agate.Table, List[Exception]]: + def get_catalog( + self, manifest: Manifest, selected_nodes: Optional[Set] = None + ) -> Tuple[agate.Table, List[Exception]]: schema_map = self._get_catalog_schemas(manifest) if len(schema_map) > 1: raise dbt.exceptions.CompilationError( diff --git a/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py b/tests/functional/adapter/test_store_test_failures.py similarity index 62% rename from tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py rename to tests/functional/adapter/test_store_test_failures.py index c445fe671..e27cb9b95 100644 --- a/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py +++ b/tests/functional/adapter/test_store_test_failures.py @@ -1,5 +1,6 @@ import pytest +from dbt.tests.adapter.store_test_failures_tests import basic from dbt.tests.adapter.store_test_failures_tests.test_store_test_failures import ( StoreTestFailuresBase, TEST_AUDIT_SCHEMA_SUFFIX, @@ -42,3 +43,33 @@ def project_config_update(self): def test_store_and_assert_failure_with_delta(self, project): self.run_tests_store_one_failure(project) self.run_tests_store_failures_and_assert(project) + + +@pytest.mark.skip_profile("spark_session") +class TestStoreTestFailuresAsInteractions(basic.StoreTestFailuresAsInteractions): + pass + + +@pytest.mark.skip_profile("spark_session") +class TestStoreTestFailuresAsProjectLevelOff(basic.StoreTestFailuresAsProjectLevelOff): + pass + + +@pytest.mark.skip_profile("spark_session") +class TestStoreTestFailuresAsProjectLevelView(basic.StoreTestFailuresAsProjectLevelView): + pass + + +@pytest.mark.skip_profile("spark_session") +class TestStoreTestFailuresAsGeneric(basic.StoreTestFailuresAsGeneric): + pass + + +@pytest.mark.skip_profile("spark_session") +class TestStoreTestFailuresAsProjectLevelEphemeral(basic.StoreTestFailuresAsProjectLevelEphemeral): + pass + + +@pytest.mark.skip_profile("spark_session") +class TestStoreTestFailuresAsExceptions(basic.StoreTestFailuresAsExceptions): + pass