Skip to content

Commit

Permalink
Inspect only once per schema
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Dec 3, 2024
1 parent 1bf62d9 commit d291084
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions singer_sdk/connectors/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,30 +1056,26 @@ def discover_catalog_entries(
if schema_name in exclude_schemas:
continue

primary_keys = inspected.get_multi_pk_constraint(schema=schema_name)

if reflect_indices:
constraints = inspected.get_multi_unique_constraints(schema=schema_name)
else:
constraints = {}

for object_kind, is_view in object_kinds:
columns = inspected.get_multi_columns(
schema=schema_name,
kind=object_kind,
)
primary_keys = inspected.get_multi_pk_constraint(
schema=schema_name, kind=object_kind
)

if reflect_indices:
unique_constraints = inspected.get_multi_unique_constraints(
schema=schema_name,
kind=object_kind,
)
else:
unique_constraints = {}

result.extend(
self._discover_catalog_entry_from_inspected(
table_name=table,
schema_name=schema,
columns=columns[schema, table],
primary_key=primary_keys.get((schema, table)),
unique_constraints=unique_constraints.get((schema, table), []),
unique_constraints=constraints.get((schema, table), []),
is_view=is_view,
).to_dict()
for schema, table in columns
Expand Down

0 comments on commit d291084

Please sign in to comment.