Skip to content

Commit 821848b

Browse files
refactor(sql): Simplify primary key fallback logic with one-liner
Address @aaronsteers feedback to use more concise approach: pks = configured_stream.primary_key or configured_stream.stream.source_defined_primary_key or [] This maintains exact same functionality while being more readable. Co-Authored-By: AJ Steers <[email protected]>
1 parent 065e737 commit 821848b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

airbyte_cdk/sql/shared/catalog_providers.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,11 @@ def get_primary_keys(
122122
) -> list[str]:
123123
"""Return the primary keys for the given stream."""
124124
configured_stream = self.get_configured_stream_info(stream_name)
125-
pks = configured_stream.primary_key
126-
127-
if not pks:
128-
pks = configured_stream.stream.source_defined_primary_key
129-
if not pks:
130-
return []
125+
pks = (
126+
configured_stream.primary_key
127+
or configured_stream.stream.source_defined_primary_key
128+
or []
129+
)
131130

132131
normalized_pks: list[list[str]] = [
133132
[LowerCaseNormalizer.normalize(c) for c in pk] for pk in pks

0 commit comments

Comments
 (0)