Skip to content

Commit

Permalink
feat: Emit Postgres schema as _sdc_postgres_schema
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Aug 5, 2024
1 parent d196204 commit a9188ce
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tap_postgres/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,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 @@ -326,6 +333,7 @@ def get_records(self, context: dict | 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

0 comments on commit a9188ce

Please sign in to comment.