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: log based replication #249

Merged
merged 20 commits into from
Oct 16, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
linting with ruff and black
  • Loading branch information
sebastianswms committed Oct 16, 2023
commit 3db019ca3f52a7a233a690aa03cc8b385974a7a8
24 changes: 20 additions & 4 deletions tap_postgres/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
import paramiko
from singer_sdk import SQLTap, Stream
from singer_sdk import typing as th
from singer_sdk._singerlib import Catalog, Metadata, Schema # JSON schema typing helpers
from singer_sdk._singerlib import ( # JSON schema typing helpers
Catalog,
Metadata,
Schema,
)
from sqlalchemy.engine import URL
from sqlalchemy.engine.url import make_url
from sshtunnel import SSHTunnelForwarder
Expand Down Expand Up @@ -513,7 +517,7 @@ def catalog_dict(self) -> dict:
@property
def catalog(self) -> Catalog:
return self.modify_catalog(super().catalog)

def modify_catalog(self, catalog: Catalog) -> dict:
new_catalog: Catalog = Catalog()
modified_streams: list = []
Expand All @@ -533,13 +537,25 @@ def modify_catalog(self, catalog: Catalog) -> dict:
new_stream.schema.properties.update(
{"_sdc_deleted_at": Schema(type=["string", "null"])}
)
new_stream.metadata.update({("properties", "_sdc_deleted_at"): Metadata(Metadata.InclusionType.AVAILABLE, True, None)})
new_stream.metadata.update(
{
("properties", "_sdc_deleted_at"): Metadata(
Metadata.InclusionType.AVAILABLE, True, None
)
}
)
if "_sdc_lsn" not in new_stream.schema.properties:
stream_modified = True
new_stream.schema.properties.update(
{"_sdc_lsn": Schema(type=["integer", "null"])}
)
new_stream.metadata.update({("properties", "_sdc_lsn"): Metadata(Metadata.InclusionType.AVAILABLE, True, None)})
new_stream.metadata.update(
{
("properties", "_sdc_lsn"): Metadata(
Metadata.InclusionType.AVAILABLE, True, None
)
}
)
if stream_modified:
modified_streams.append(new_stream.tap_stream_id)
new_catalog.add_stream(new_stream)
Expand Down
Loading