From f17bbac0fd993d34f2514aac6b42e2454c3c3e0a Mon Sep 17 00:00:00 2001 From: Stu Kilgore Date: Mon, 10 Apr 2023 17:04:52 -0500 Subject: [PATCH] Add possible implementation for CT-1498 --- core/dbt/adapters/base/impl.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/dbt/adapters/base/impl.py b/core/dbt/adapters/base/impl.py index 6bf86b90bde..014f89902ef 100644 --- a/core/dbt/adapters/base/impl.py +++ b/core/dbt/adapters/base/impl.py @@ -718,6 +718,24 @@ def list_relations(self, database: Optional[str], schema: str) -> List[BaseRelat # we can't build the relations cache because we don't have a # manifest so we can't run any operations. relations = self.list_relations_without_caching(schema_relation) + + # if the cache is already populated, add this schema in + # otherwise, skip updating the cache and just ignore + if self.cache: + for relation in relations: + self.cache.add(relation) + if not relations: + # it's possible that there were no relations in some schemas. We want + # to insert the schemas we query into the cache's `.schemas` attribute + # so we can check it later + + # Jeremy: what was the intent behind this inner loop? + # cache_update: Set[Tuple[Optional[str], Optional[str]]] = set() + # for relation in cache_schemas: + # cache_update.add((database, schema)) + + self.cache.update_schemas(set((database, schema))) + fire_event( ListRelations( database=cast_to_str(database),