From 17c245fcaf4eaaa649fa0b3f5f6764f2aa317821 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 15 Dec 2023 22:35:13 -0500 Subject: [PATCH] guard against multiple info schemas in get_catalog_by_relations --- dbt/adapters/spark/impl.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/dbt/adapters/spark/impl.py b/dbt/adapters/spark/impl.py index a07a66691..aeddd9d6c 100644 --- a/dbt/adapters/spark/impl.py +++ b/dbt/adapters/spark/impl.py @@ -386,22 +386,23 @@ def get_catalog_by_relations( self, manifest: Manifest, relations: Set[BaseRelation] ) -> Tuple[agate.Table, List[Exception]]: relations_by_info_schema = self._get_catalog_relations_by_info_schema(relations) + if len(relations_by_info_schema) != 1: + raise dbt.exceptions.CompilationError( + f"Expected exactly one information schema in get_catalog_by_relations, " + f"found {list(relations_by_info_schema)}" + ) with executor(self.config) as tpe: - futures: List[Future[agate.Table]] = [] - for info_schema, relations_in_info_schema in relations_by_info_schema.items(): - for relation in relations_in_info_schema: - futures.append( - tpe.submit_connected( - self, - relation.schema, - self._get_one_catalog_by_relations, - info_schema, - [relation], - manifest, - ) - ) - catalogs, exceptions = catch_as_completed(futures) + info_schema, relations_in_info_schema = set(relations_by_info_schema.items()).pop() + future = tpe.submit_connected( + self, + info_schema.database, + self._get_one_catalog_by_relations, + info_schema, + relations_in_info_schema, + manifest, + ) + catalogs, exceptions = catch_as_completed([future]) return catalogs, exceptions def _get_one_catalog(