From 1c021066ea96db69d3e7c5fd5f47bc711a260b6b Mon Sep 17 00:00:00 2001 From: case-k-git Date: Sat, 9 Dec 2023 23:54:59 +0900 Subject: [PATCH 1/5] update-schema-check-validation --- dbt/adapters/databricks/impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index 0b8fdf47..4eed34c4 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -169,7 +169,7 @@ def list_schemas(self, database: Optional[str]) -> List[str]: def check_schema_exists(self, database: Optional[str], schema: str) -> bool: """Check if a schema exists.""" - return schema.lower() in set(s.lower() for s in self.list_schemas(database=database)) + return schema in set(s for s in self.list_schemas(database=database)) def execute( self, From 9a8c1e4323adba113ba6e41ee0c8eac9151c28ca Mon Sep 17 00:00:00 2001 From: case-k-git Date: Sun, 10 Dec 2023 00:11:25 +0900 Subject: [PATCH 2/5] refactor schema check function --- dbt/adapters/databricks/impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index 4eed34c4..9ffd2662 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -169,7 +169,7 @@ def list_schemas(self, database: Optional[str]) -> List[str]: def check_schema_exists(self, database: Optional[str], schema: str) -> bool: """Check if a schema exists.""" - return schema in set(s for s in self.list_schemas(database=database)) + return schema in set(self.list_schemas(database=database)) def execute( self, From 7fb8a172d787814857f1bfeb2c17fae0e42b5bf6 Mon Sep 17 00:00:00 2001 From: case-k-git Date: Fri, 29 Dec 2023 18:41:07 +0900 Subject: [PATCH 3/5] fix schema check when executing incremental method --- dbt/adapters/databricks/connections.py | 4 ++-- dbt/adapters/databricks/impl.py | 2 +- tests/integration/base.py | 2 +- .../incremental_strategies/test_incremental_strategies.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dbt/adapters/databricks/connections.py b/dbt/adapters/databricks/connections.py index 09292028..5d7871e6 100644 --- a/dbt/adapters/databricks/connections.py +++ b/dbt/adapters/databricks/connections.py @@ -1181,7 +1181,7 @@ def _execute_cursor( def list_schemas(self, database: str, schema: Optional[str] = None) -> Table: database = database.strip("`") if schema: - schema = schema.strip("`") + schema = schema.strip("`").lower() return self._execute_cursor( f"GetSchemas(database={database}, schema={schema})", lambda cursor: cursor.schemas(catalog_name=database, schema_name=schema), @@ -1189,7 +1189,7 @@ def list_schemas(self, database: str, schema: Optional[str] = None) -> Table: def list_tables(self, database: str, schema: str, identifier: Optional[str] = None) -> Table: database = database.strip("`") - schema = schema.strip("`") + schema = schema.strip("`").lower() if identifier: identifier = identifier.strip("`") return self._execute_cursor( diff --git a/dbt/adapters/databricks/impl.py b/dbt/adapters/databricks/impl.py index 9ffd2662..0b8fdf47 100644 --- a/dbt/adapters/databricks/impl.py +++ b/dbt/adapters/databricks/impl.py @@ -169,7 +169,7 @@ def list_schemas(self, database: Optional[str]) -> List[str]: def check_schema_exists(self, database: Optional[str], schema: str) -> bool: """Check if a schema exists.""" - return schema in set(self.list_schemas(database=database)) + return schema.lower() in set(s.lower() for s in self.list_schemas(database=database)) def execute( self, diff --git a/tests/integration/base.py b/tests/integration/base.py index 8bb8c94f..a6522a89 100644 --- a/tests/integration/base.py +++ b/tests/integration/base.py @@ -171,7 +171,7 @@ def unique_schema(self): to_return = "{}_{}".format(self.prefix, schema) - return to_return.lower() + return to_return @property def default_database(self): diff --git a/tests/integration/incremental_strategies/test_incremental_strategies.py b/tests/integration/incremental_strategies/test_incremental_strategies.py index 53a2cc88..7640c5bf 100644 --- a/tests/integration/incremental_strategies/test_incremental_strategies.py +++ b/tests/integration/incremental_strategies/test_incremental_strategies.py @@ -4,7 +4,7 @@ class TestIncrementalStrategies(DBTIntegrationTest): @property def schema(self): - return "incremental_strategies" + return "Incremental_strategies" @property def project_config(self): From 0e30975659f858001cb874208f605e4c7ddeb390 Mon Sep 17 00:00:00 2001 From: case-k-git Date: Fri, 12 Jan 2024 09:35:03 +0900 Subject: [PATCH 4/5] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d0df1d..ea3af389 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix for issue where long-running python models led to invalid session errors ([544](https://github.com/databricks/dbt-databricks/pull/544)) - Allow schema to be specified in testing (thanks @case-k-git!) ([538](https://github.com/databricks/dbt-databricks/pull/538)) +- Fix dbt incremental_strategy behavior by fixing schema table existing check ([530](https://github.com/databricks/dbt-databricks/pull/530)) ## dbt-databricks 1.7.3 (Dec 12, 2023) From ac0cab631097e5cf180bfdeaea8b54dfb6f34cd9 Mon Sep 17 00:00:00 2001 From: Ben Cassell <98852248+benc-db@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:07:01 -0800 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea3af389..4faff37d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Fix for issue where long-running python models led to invalid session errors ([544](https://github.com/databricks/dbt-databricks/pull/544)) - Allow schema to be specified in testing (thanks @case-k-git!) ([538](https://github.com/databricks/dbt-databricks/pull/538)) -- Fix dbt incremental_strategy behavior by fixing schema table existing check ([530](https://github.com/databricks/dbt-databricks/pull/530)) +- Fix dbt incremental_strategy behavior by fixing schema table existing check (thanks @case-k-git!) ([530](https://github.com/databricks/dbt-databricks/pull/530)) ## dbt-databricks 1.7.3 (Dec 12, 2023)