Skip to content

Commit

Permalink
guard against multiple info schemas in get_catalog_by_relations
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Dec 16, 2023
1 parent 73979ee commit 17c245f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions dbt/adapters/spark/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 17c245f

Please sign in to comment.