Skip to content

Commit 88bc922

Browse files
refactor: Use the default offset paginator (#265)
Should be possible with meltano/sdk#1918
1 parent 74e03eb commit 88bc922

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

tap_dbt/streams.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,9 @@
1111

1212
from tap_dbt.client import DBTStream
1313

14-
if t.TYPE_CHECKING:
15-
import requests
16-
1714
SCHEMAS_DIR = Path(__file__).parent / Path("./schemas")
1815

1916

20-
class DbtPaginator(BaseOffsetPaginator):
21-
"""dbt API paginator."""
22-
23-
def has_more(self, response: requests.Response) -> bool:
24-
"""Returns True until there are no more pages to retrieve.
25-
26-
The API returns an 'extra' key with information about pagination:
27-
"extra":{"filters":{"limit":100,"offset":2,"account_id":1},"order_by":"id","pagination":{"count":100,"total_count":209}}}
28-
"""
29-
data = response.json()
30-
extra = data.get("extra", {})
31-
filters = extra.get("filters", {})
32-
pagination = extra.get("pagination", {})
33-
34-
offset = filters.get("offset", 0)
35-
total_count = pagination.get("total_count")
36-
count = pagination.get("count")
37-
38-
# The pagination has more records when:
39-
# total_count is still greater than count and offset combined
40-
return count + offset < total_count
41-
42-
4317
class AccountBasedStream(DBTStream):
4418
"""A stream that requires an account ID."""
4519

@@ -59,7 +33,7 @@ def partitions(self) -> list[dict]:
5933
)
6034
raise ValueError(errmsg)
6135

62-
def get_new_paginator(self) -> DbtPaginator:
36+
def get_new_paginator(self) -> BaseOffsetPaginator:
6337
"""Return a new paginator instance for this stream."""
6438
page_size = self.config["page_size"]
6539

@@ -68,7 +42,7 @@ def get_new_paginator(self) -> DbtPaginator:
6842
page_size,
6943
)
7044

71-
return DbtPaginator(start_value=0, page_size=page_size)
45+
return BaseOffsetPaginator(start_value=0, page_size=page_size)
7246

7347
def get_url_params(
7448
self,

0 commit comments

Comments
 (0)