From bbfb411d0cc86b5ea3b0a54e01e04e68c2b1cfe3 Mon Sep 17 00:00:00 2001 From: Paul Teehan Date: Fri, 28 Nov 2025 21:40:56 +0100 Subject: [PATCH 01/12] Refactor schema and db prefixes --- .../athena_data_source_test_helper.py | 2 +- .../data_sources/bigquery_data_source.py | 6 +-- .../src/soda_core/common/data_source_impl.py | 51 +++++++++++-------- .../sqlserver_data_source_test_helper.py | 2 +- .../src/helpers/data_source_test_helper.py | 22 ++++---- 5 files changed, 45 insertions(+), 38 deletions(-) diff --git a/soda-athena/src/soda_athena/test_helpers/athena_data_source_test_helper.py b/soda-athena/src/soda_athena/test_helpers/athena_data_source_test_helper.py index 6a99aba9c..8725b9bc2 100644 --- a/soda-athena/src/soda_athena/test_helpers/athena_data_source_test_helper.py +++ b/soda-athena/src/soda_athena/test_helpers/athena_data_source_test_helper.py @@ -47,7 +47,7 @@ def _create_data_source_yaml_str(self) -> str: """ def _get_3_schema_dir(self): - schema_name = self.dataset_prefix[self.data_source_impl.sql_dialect.get_schema_prefix_index()] + schema_name = self.extract_schema_from_prefix() return f"{self.s3_test_dir}/staging-dir/{ATHENA_CATALOG}/{schema_name}" def drop_test_schema_if_exists(self) -> str: diff --git a/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py b/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py index 1b9837783..695875209 100644 --- a/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py +++ b/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py @@ -96,16 +96,14 @@ def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[ project_id=prefixes[0], dataset=None, # We only need the project id to query the schemas, as it's always in the `INFORMATION_SCHEMA` ) - - schema_index: int | None = self.sql_dialect.get_schema_prefix_index() - - schema_name: str = prefixes[schema_index] if schema_index is not None and schema_index < len(prefixes) else None + schema_name = self.extract_schema_from_prefix(prefixes) if schema_name is None: raise ValueError(f"Cannot determine schema name from prefixes: {prefixes}") return table_namespace, schema_name + class BigQuerySqlDialect(SqlDialect): DEFAULT_QUOTE_CHAR = "`" diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 249bb0ead..7bc01a605 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -162,13 +162,14 @@ def get_columns_metadata(self, dataset_prefixes: list[str], dataset_name: str) - return self.sql_dialect.build_column_metadatas_from_query_result(query_result) def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_name: str) -> str: - database_index: int | None = self.sql_dialect.get_database_prefix_index() - schema_index: int | None = self.sql_dialect.get_schema_prefix_index() + schema_name: str = self.extract_schema_from_prefix(dataset_prefixes) + database_name: str = self.extract_database_from_prefix(dataset_prefixes) + table_namespace: DataSourceNamespace = ( - SchemaDataSourceNamespace(schema=dataset_prefixes[schema_index]) - if database_index is None + SchemaDataSourceNamespace(schema=schema_name) + if database_name is None else DbSchemaDataSourceNamespace( - database=dataset_prefixes[database_index], schema=dataset_prefixes[schema_index] + database=database_name, schema=schema_name ) ) @@ -177,28 +178,39 @@ def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_ table_namespace=table_namespace, table_name=dataset_name ) + + + def extract_schema_from_prefix(self, prefixes: list[str]) -> str: + schema_index: int | None = self.sql_dialect.get_schema_prefix_index() + if schema_index is None: + return None + schema_name: str = prefixes[schema_index] if schema_index is not None and schema_index < len(prefixes) else None + return schema_name + + def extract_database_from_prefix(self, prefixes: list[str]) -> str: + database_index: int | None = self.sql_dialect.get_database_prefix_index() + if database_index is None: + return None + database_name: str = prefixes[database_index] if database_index is not None and database_index < len(prefixes) else None + return database_name + def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[DataSourceNamespace, str]: """ Builds the table namespace for the schema query. Returns the table namespace and the schema name. - """ + """ + schema_name: str = self.extract_schema_from_prefix(prefixes) + database_name: str | None = self.extract_database_from_prefix(prefixes) database_index: int | None = self.sql_dialect.get_database_prefix_index() - schema_index: int | None = self.sql_dialect.get_schema_prefix_index() - - schema_name: str = prefixes[schema_index] if schema_index is not None and schema_index < len(prefixes) else None if schema_name is None: raise ValueError(f"Cannot determine schema name from prefixes: {prefixes}") - database_name: str | None = ( - prefixes[database_index] if database_index is not None and database_index < len(prefixes) else None - ) - table_namespace: DataSourceNamespace = ( - SchemaDataSourceNamespace(schema=prefixes[schema_index]) + SchemaDataSourceNamespace(schema=schema_name) if database_index is None else DbSchemaDataSourceNamespace( database=database_name, - schema=prefixes[schema_index], + schema=schema_name, ) ) return table_namespace, schema_name @@ -232,12 +244,9 @@ def verify_if_table_exists(self, prefixes: list[str], table_name: str) -> bool: def _get_fully_qualified_table_names(self, prefixes: list[str], table_name: str) -> list[FullyQualifiedTableName]: metadata_tables_query: MetadataTablesQuery = self.create_metadata_tables_query() - database_index = self.sql_dialect.get_database_prefix_index() - schema_index = self.sql_dialect.get_schema_prefix_index() - database_name = ( - prefixes[database_index] if database_index is not None and database_index < len(prefixes) else None - ) - schema_name = prefixes[schema_index] if schema_index is not None and schema_index < len(prefixes) else None + database_name = self.extract_database_from_prefix(prefixes) + schema_name = self.extract_schema_from_prefix(prefixes) + fully_qualified_table_names: list[FullyQualifiedTableName] = metadata_tables_query.execute( database_name=database_name, schema_name=schema_name, diff --git a/soda-sqlserver/src/soda_sqlserver/test_helpers/sqlserver_data_source_test_helper.py b/soda-sqlserver/src/soda_sqlserver/test_helpers/sqlserver_data_source_test_helper.py index 5dc4867f9..2b50db9dd 100644 --- a/soda-sqlserver/src/soda_sqlserver/test_helpers/sqlserver_data_source_test_helper.py +++ b/soda-sqlserver/src/soda_sqlserver/test_helpers/sqlserver_data_source_test_helper.py @@ -46,7 +46,7 @@ def drop_test_schema_if_exists(self) -> None: drop_table_sql = dialect.build_drop_table_sql(DROP_TABLE(table_identifier)) self.data_source_impl.execute_update(drop_table_sql) # Drop the schema if it exists. - schema_name = self.dataset_prefix[self.data_source_impl.sql_dialect.get_schema_prefix_index()] + schema_name = self.extract_schema_from_prefix() if self._does_schema_exist(schema_name): self.data_source_impl.execute_update(f"DROP SCHEMA {dialect.quote_default(schema_name)};") diff --git a/soda-tests/src/helpers/data_source_test_helper.py b/soda-tests/src/helpers/data_source_test_helper.py index 061897031..a6b42a45d 100644 --- a/soda-tests/src/helpers/data_source_test_helper.py +++ b/soda-tests/src/helpers/data_source_test_helper.py @@ -277,14 +277,9 @@ def end_test_session_drop_schema(self) -> None: self.drop_test_schema_if_exists() def query_existing_test_tables(self) -> list[FullyQualifiedTableName]: - database: Optional[str] = None - if self.data_source_impl.sql_dialect.get_database_prefix_index() is not None: - database = self.dataset_prefix[self.data_source_impl.sql_dialect.get_database_prefix_index()] - - schema: Optional[str] = None - if self.data_source_impl.sql_dialect.get_schema_prefix_index() is not None: - schema = self.dataset_prefix[self.data_source_impl.sql_dialect.get_schema_prefix_index()] - + database: Optional[str] = self.extract_database_from_prefix() + schema: Optional[str] = self.extract_schema_from_prefix() + metadata_tables_query: MetadataTablesQuery = self.data_source_impl.create_metadata_tables_query() fully_qualified_table_names: list[FullyQualifiedTableName] = metadata_tables_query.execute( database_name=database, @@ -313,11 +308,16 @@ def create_test_schema_if_not_exists_sql(self) -> str: def post_test_schema_create_sql(self) -> str: return self.data_source_impl.sql_dialect.post_schema_create_sql(self.dataset_prefix) + def extract_database_from_prefix(self) -> str: + return self.data_source_impl.extract_database_from_prefix(self.dataset_prefix) + + def extract_schema_from_prefix(self) -> str: + return self.data_source_impl.extract_schema_from_prefix(self.dataset_prefix) + def drop_test_schema_if_exists(self) -> None: - schema_index = self.data_source_impl.sql_dialect.get_schema_prefix_index() - if schema_index is None: + schema = self.extract_schema_from_prefix() + if not schema: raise AssertionError("Data source does not support schemas") - schema = self.dataset_prefix[schema_index] self.drop_schema_if_exists(schema) From 1d724b9372f5b71c7e941dcee8ee96812d1e7eab Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 28 Nov 2025 20:43:20 +0000 Subject: [PATCH 02/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../data_sources/bigquery_data_source.py | 1 - .../src/soda_core/common/data_source_impl.py | 18 ++++++++---------- .../src/helpers/data_source_test_helper.py | 6 +++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py b/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py index 695875209..caee0ec50 100644 --- a/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py +++ b/soda-bigquery/src/soda_bigquery/common/data_sources/bigquery_data_source.py @@ -103,7 +103,6 @@ def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[ return table_namespace, schema_name - class BigQuerySqlDialect(SqlDialect): DEFAULT_QUOTE_CHAR = "`" diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 7bc01a605..635593f73 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -164,13 +164,11 @@ def get_columns_metadata(self, dataset_prefixes: list[str], dataset_name: str) - def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_name: str) -> str: schema_name: str = self.extract_schema_from_prefix(dataset_prefixes) database_name: str = self.extract_database_from_prefix(dataset_prefixes) - + table_namespace: DataSourceNamespace = ( SchemaDataSourceNamespace(schema=schema_name) if database_name is None - else DbSchemaDataSourceNamespace( - database=database_name, schema=schema_name - ) + else DbSchemaDataSourceNamespace(database=database_name, schema=schema_name) ) # BigQuery must be able to override to get the location @@ -178,9 +176,7 @@ def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_ table_namespace=table_namespace, table_name=dataset_name ) - - - def extract_schema_from_prefix(self, prefixes: list[str]) -> str: + def extract_schema_from_prefix(self, prefixes: list[str]) -> str: schema_index: int | None = self.sql_dialect.get_schema_prefix_index() if schema_index is None: return None @@ -191,14 +187,16 @@ def extract_database_from_prefix(self, prefixes: list[str]) -> str: database_index: int | None = self.sql_dialect.get_database_prefix_index() if database_index is None: return None - database_name: str = prefixes[database_index] if database_index is not None and database_index < len(prefixes) else None + database_name: str = ( + prefixes[database_index] if database_index is not None and database_index < len(prefixes) else None + ) return database_name def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[DataSourceNamespace, str]: """ Builds the table namespace for the schema query. Returns the table namespace and the schema name. - """ + """ schema_name: str = self.extract_schema_from_prefix(prefixes) database_name: str | None = self.extract_database_from_prefix(prefixes) database_index: int | None = self.sql_dialect.get_database_prefix_index() @@ -246,7 +244,7 @@ def _get_fully_qualified_table_names(self, prefixes: list[str], table_name: str) metadata_tables_query: MetadataTablesQuery = self.create_metadata_tables_query() database_name = self.extract_database_from_prefix(prefixes) schema_name = self.extract_schema_from_prefix(prefixes) - + fully_qualified_table_names: list[FullyQualifiedTableName] = metadata_tables_query.execute( database_name=database_name, schema_name=schema_name, diff --git a/soda-tests/src/helpers/data_source_test_helper.py b/soda-tests/src/helpers/data_source_test_helper.py index a6b42a45d..a9cd44d78 100644 --- a/soda-tests/src/helpers/data_source_test_helper.py +++ b/soda-tests/src/helpers/data_source_test_helper.py @@ -279,7 +279,7 @@ def end_test_session_drop_schema(self) -> None: def query_existing_test_tables(self) -> list[FullyQualifiedTableName]: database: Optional[str] = self.extract_database_from_prefix() schema: Optional[str] = self.extract_schema_from_prefix() - + metadata_tables_query: MetadataTablesQuery = self.data_source_impl.create_metadata_tables_query() fully_qualified_table_names: list[FullyQualifiedTableName] = metadata_tables_query.execute( database_name=database, @@ -310,10 +310,10 @@ def post_test_schema_create_sql(self) -> str: def extract_database_from_prefix(self) -> str: return self.data_source_impl.extract_database_from_prefix(self.dataset_prefix) - + def extract_schema_from_prefix(self) -> str: return self.data_source_impl.extract_schema_from_prefix(self.dataset_prefix) - + def drop_test_schema_if_exists(self) -> None: schema = self.extract_schema_from_prefix() if not schema: From b47726fe7d302249c5072d8eaf2d54997b169c33 Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:46:51 +0100 Subject: [PATCH 03/12] Update soda-core/src/soda_core/common/data_source_impl.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-core/src/soda_core/common/data_source_impl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 635593f73..dbfdcd493 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -176,14 +176,14 @@ def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_ table_namespace=table_namespace, table_name=dataset_name ) - def extract_schema_from_prefix(self, prefixes: list[str]) -> str: + def extract_schema_from_prefix(self, prefixes: list[str]) -> Optional[str]: schema_index: int | None = self.sql_dialect.get_schema_prefix_index() if schema_index is None: return None schema_name: str = prefixes[schema_index] if schema_index is not None and schema_index < len(prefixes) else None return schema_name - def extract_database_from_prefix(self, prefixes: list[str]) -> str: + def extract_database_from_prefix(self, prefixes: list[str]) -> Optional[str]: database_index: int | None = self.sql_dialect.get_database_prefix_index() if database_index is None: return None From 398176d42eabb62e29cd73fa0cae8d53536f7348 Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:47:14 +0100 Subject: [PATCH 04/12] Update soda-core/src/soda_core/common/data_source_impl.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-core/src/soda_core/common/data_source_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index dbfdcd493..89d0b34e8 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -180,7 +180,7 @@ def extract_schema_from_prefix(self, prefixes: list[str]) -> Optional[str]: schema_index: int | None = self.sql_dialect.get_schema_prefix_index() if schema_index is None: return None - schema_name: str = prefixes[schema_index] if schema_index is not None and schema_index < len(prefixes) else None + schema_name: str = prefixes[schema_index] if schema_index < len(prefixes) else None return schema_name def extract_database_from_prefix(self, prefixes: list[str]) -> Optional[str]: From e75249392656d97cbe22833b1010f1272a5bb260 Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:47:57 +0100 Subject: [PATCH 05/12] Update soda-core/src/soda_core/common/data_source_impl.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-core/src/soda_core/common/data_source_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 89d0b34e8..e8550a540 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -188,7 +188,7 @@ def extract_database_from_prefix(self, prefixes: list[str]) -> Optional[str]: if database_index is None: return None database_name: str = ( - prefixes[database_index] if database_index is not None and database_index < len(prefixes) else None + prefixes[database_index] if database_index < len(prefixes) else None ) return database_name From 142883ad3e237185badc0a716edb17eb10e4232b Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:48:11 +0100 Subject: [PATCH 06/12] Update soda-tests/src/helpers/data_source_test_helper.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-tests/src/helpers/data_source_test_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-tests/src/helpers/data_source_test_helper.py b/soda-tests/src/helpers/data_source_test_helper.py index a9cd44d78..86d1733da 100644 --- a/soda-tests/src/helpers/data_source_test_helper.py +++ b/soda-tests/src/helpers/data_source_test_helper.py @@ -311,7 +311,7 @@ def post_test_schema_create_sql(self) -> str: def extract_database_from_prefix(self) -> str: return self.data_source_impl.extract_database_from_prefix(self.dataset_prefix) - def extract_schema_from_prefix(self) -> str: + def extract_schema_from_prefix(self) -> Optional[str]: return self.data_source_impl.extract_schema_from_prefix(self.dataset_prefix) def drop_test_schema_if_exists(self) -> None: From f0adfcedd508ba4ddace9b567378317cd1808bb4 Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:48:23 +0100 Subject: [PATCH 07/12] Update soda-core/src/soda_core/common/data_source_impl.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-core/src/soda_core/common/data_source_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index e8550a540..6549e3932 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -162,7 +162,7 @@ def get_columns_metadata(self, dataset_prefixes: list[str], dataset_name: str) - return self.sql_dialect.build_column_metadatas_from_query_result(query_result) def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_name: str) -> str: - schema_name: str = self.extract_schema_from_prefix(dataset_prefixes) + schema_name: Optional[str] = self.extract_schema_from_prefix(dataset_prefixes) database_name: str = self.extract_database_from_prefix(dataset_prefixes) table_namespace: DataSourceNamespace = ( From 18a197221f0166830a1e3c07a09e90283f5ab190 Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:48:34 +0100 Subject: [PATCH 08/12] Update soda-core/src/soda_core/common/data_source_impl.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-core/src/soda_core/common/data_source_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 6549e3932..08482792d 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -197,7 +197,7 @@ def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[ Builds the table namespace for the schema query. Returns the table namespace and the schema name. """ - schema_name: str = self.extract_schema_from_prefix(prefixes) + schema_name: Optional[str] = self.extract_schema_from_prefix(prefixes) database_name: str | None = self.extract_database_from_prefix(prefixes) database_index: int | None = self.sql_dialect.get_database_prefix_index() if schema_name is None: From 96fb897e589977a92fa0d892985faa5166f5e56a Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:48:47 +0100 Subject: [PATCH 09/12] Update soda-tests/src/helpers/data_source_test_helper.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-tests/src/helpers/data_source_test_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-tests/src/helpers/data_source_test_helper.py b/soda-tests/src/helpers/data_source_test_helper.py index 86d1733da..467b15bdb 100644 --- a/soda-tests/src/helpers/data_source_test_helper.py +++ b/soda-tests/src/helpers/data_source_test_helper.py @@ -308,7 +308,7 @@ def create_test_schema_if_not_exists_sql(self) -> str: def post_test_schema_create_sql(self) -> str: return self.data_source_impl.sql_dialect.post_schema_create_sql(self.dataset_prefix) - def extract_database_from_prefix(self) -> str: + def extract_database_from_prefix(self) -> Optional[str]: return self.data_source_impl.extract_database_from_prefix(self.dataset_prefix) def extract_schema_from_prefix(self) -> Optional[str]: From 7772237a0b2069a7e2394750c7cb08b171b94787 Mon Sep 17 00:00:00 2001 From: paulteehan <45394252+paulteehan@users.noreply.github.com> Date: Mon, 1 Dec 2025 15:49:33 +0100 Subject: [PATCH 10/12] Update soda-core/src/soda_core/common/data_source_impl.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- soda-core/src/soda_core/common/data_source_impl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 08482792d..43c2954a0 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -163,7 +163,7 @@ def get_columns_metadata(self, dataset_prefixes: list[str], dataset_name: str) - def build_columns_metadata_query_str(self, dataset_prefixes: list[str], dataset_name: str) -> str: schema_name: Optional[str] = self.extract_schema_from_prefix(dataset_prefixes) - database_name: str = self.extract_database_from_prefix(dataset_prefixes) + database_name: Optional[str] = self.extract_database_from_prefix(dataset_prefixes) table_namespace: DataSourceNamespace = ( SchemaDataSourceNamespace(schema=schema_name) From c594c9def9eb9be23159846b3bfa1743aede03ba Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Dec 2025 14:50:41 +0000 Subject: [PATCH 11/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- soda-core/src/soda_core/common/data_source_impl.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 43c2954a0..3d2532753 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -187,9 +187,7 @@ def extract_database_from_prefix(self, prefixes: list[str]) -> Optional[str]: database_index: int | None = self.sql_dialect.get_database_prefix_index() if database_index is None: return None - database_name: str = ( - prefixes[database_index] if database_index < len(prefixes) else None - ) + database_name: str = prefixes[database_index] if database_index < len(prefixes) else None return database_name def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[DataSourceNamespace, str]: From 449e1945b07a86f6b342cf82b0e2a4877a4a6557 Mon Sep 17 00:00:00 2001 From: Paul Teehan Date: Mon, 1 Dec 2025 17:55:53 +0100 Subject: [PATCH 12/12] cleanup --- soda-core/src/soda_core/common/data_source_impl.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/soda-core/src/soda_core/common/data_source_impl.py b/soda-core/src/soda_core/common/data_source_impl.py index 635593f73..a5949a69e 100644 --- a/soda-core/src/soda_core/common/data_source_impl.py +++ b/soda-core/src/soda_core/common/data_source_impl.py @@ -199,13 +199,12 @@ def _build_table_namespace_for_schema_query(self, prefixes: list[str]) -> tuple[ """ schema_name: str = self.extract_schema_from_prefix(prefixes) database_name: str | None = self.extract_database_from_prefix(prefixes) - database_index: int | None = self.sql_dialect.get_database_prefix_index() if schema_name is None: raise ValueError(f"Cannot determine schema name from prefixes: {prefixes}") table_namespace: DataSourceNamespace = ( SchemaDataSourceNamespace(schema=schema_name) - if database_index is None + if database_name is None else DbSchemaDataSourceNamespace( database=database_name, schema=schema_name,