Hi, I am using python airbyte_cdk to write my own ...
# replication-troubleshooting
i
Hi, I am using python airbyte_cdk to write my own connector and have some difficulties with
stream_slices
method. Is there a way to compute next slice depending on the state after the previous slice? My problem. Source HTTP GET api supports parameters:
start_datetime
,
end_datetime
,
max_rows
(the last one has the maximum value of 1_000_000). I need to download 2023-02-20...2023-02-22. The slices are [2023-02-20, 2023-02-21, 2023-02-22]. But if I have more than
max_rows
entries to fetch in one date (e.g. 1_200_000, then 200_000 entries get lost), because the cdk goes to the next slice that has been computed before, and there is no way to know how many rows in advance.
w
you are right in that you would need to modify stream slices. There is no restriction on what you toss into the state "dict". For example I have used state to not only track the date being used for incremental reading, but also metadata about the streams themselves. you could potentially have state be { 'rows_remaining': 20000 , "date_read" : '2023-02-20' } stream slice gets called before reading occurs, so If you have no idea what the amount of rows returned would be, you may need to have a stream class variables called rows_remaining and last_read_date. in read_records: if rows_remaining >0: read_records(feed the parameters except use last_read_date as the stream slice value) ... normal read records stuff ... last_read_date = stream_slice rows_remaining = rows remaining?? (not sure how you get to this. maybe if rows returned = max rows you would know to try and rerun the function
i
Thank you very much for your replay. Seems like a valid approach, I will try it