Skip to content

Commit

Permalink
fix: Treat streams with LOG_BASED replication as unsorted (#301)
Browse files Browse the repository at this point in the history
Closes #297
  • Loading branch information
edgarrmondragon authored Nov 30, 2023
1 parent 4dea8aa commit 28c9b64
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tap_postgres/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This includes PostgresStream and PostgresConnector.
"""

from __future__ import annotations

import datetime
Expand All @@ -20,6 +21,7 @@
from singer_sdk import typing as th
from singer_sdk.helpers._state import increment_state
from singer_sdk.helpers._typing import TypeConformanceLevel
from singer_sdk.streams.core import REPLICATION_INCREMENTAL
from sqlalchemy import nullsfirst
from sqlalchemy.engine import Engine
from sqlalchemy.engine.reflection import Inspector
Expand Down Expand Up @@ -481,3 +483,10 @@ def logical_replication_connection(self):
application_name="tap_postgres",
connection_factory=extras.LogicalReplicationConnection,
)

# TODO: Make this change upstream in the SDK?
# I'm not sure if in general SQL databases don't guarantee order of records log
# replication, but at least Postgres does not.
def is_sorted(self) -> bool:
"""Return True if the stream is sorted by the replication key."""
return self.replication_method == REPLICATION_INCREMENTAL

0 comments on commit 28c9b64

Please sign in to comment.