Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Automatic catalog selection of replication keys #1283

2 changes: 2 additions & 0 deletions singer_sdk/_singerlib/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ def get_standard_metadata(
for field_name in schema.get("properties", {}).keys():
if key_properties and field_name in key_properties:
entry = Metadata(inclusion=Metadata.InclusionType.AUTOMATIC)
elif valid_replication_keys and field_name in valid_replication_keys:
entry = Metadata(inclusion=Metadata.InclusionType.AUTOMATIC)
else:
entry = Metadata(inclusion=Metadata.InclusionType.AVAILABLE)

Expand Down
6 changes: 6 additions & 0 deletions tests/_singerlib/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def test_catalog_parsing():
"properties": {
"first_name": {"type": "string"},
"last_name": {"type": "string"},
"updated_at": {"type": "string", "format": "date-time"},
},
"type": "object",
},
Expand Down Expand Up @@ -265,3 +266,8 @@ def test_standard_metadata(
pk_metadata = metadata[("properties", pk)]
assert pk_metadata.inclusion == Metadata.InclusionType.AUTOMATIC
assert pk_metadata.selected is None

for rk in valid_replication_keys or []:
rk_metadata = metadata[("properties", rk)]
assert rk_metadata.inclusion == Metadata.InclusionType.AUTOMATIC
assert rk_metadata.selected is None