Skip to content

Commit

Permalink
fix: push _MAX_RECORDS_LIMIT down into SQL (#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Payne authored Oct 26, 2022
1 parent 1d1ba19 commit 0122d47
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions singer_sdk/streams/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def get_records(self, context: dict | None) -> Iterable[dict[str, Any]]:
column_names=selected_column_names,
)
query = table.select()

if self.replication_key:
replication_key_col = table.columns[self.replication_key]
query = query.order_by(replication_key_col)
Expand All @@ -193,6 +194,9 @@ def get_records(self, context: dict | None) -> Iterable[dict[str, Any]]:
)
)

if self._MAX_RECORDS_LIMIT is not None:
query = query.limit(self._MAX_RECORDS_LIMIT)

for record in self.connector.connection.execute(query):
yield dict(record)

Expand Down

0 comments on commit 0122d47

Please sign in to comment.