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: Emit Postgres schema as _sdc_postgres_schema #466

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tap_postgres/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ class PostgresStream(SQLStream):
# JSONB Objects won't be selected without type_conformance_level to ROOT_ONLY
TYPE_CONFORMANCE_LEVEL = TypeConformanceLevel.ROOT_ONLY

@cached_property
def schema(self) -> dict:
"""Override schema adding _sdc columns."""
schema_dict = self._singer_catalog_entry.schema.to_dict()
schema_dict["properties"]["_sdc_postgres_schema"] = {"type": ["string", "null"]}
return schema_dict

def max_record_count(self) -> int | None:
"""Return the maximum number of records to fetch in a single query."""
return self.config.get("max_record_count")
Expand Down Expand Up @@ -392,6 +399,7 @@ def get_records(self, context: Context | None) -> t.Iterable[dict[str, t.Any]]:
# TODO: Standardize record mapping type
# https://github.com/meltano/sdk/issues/2096
transformed_record = self.post_process(dict(record))
transformed_record["_sdc_postgres_schema"] = table.schema
if transformed_record is None:
# Record filtered out during post_process()
continue
Expand Down
Loading