def advance_bookmark(stream, bookmark_key, date):
tap_stream_id = stream.name
state = stream.state or {}
LOGGER.info('advance(%s, %s)', tap_stream_id, date)
date = pendulum.parse(date) if date else None
current_bookmark = get_start(stream, bookmark_key)
if date is None:
LOGGER.info('Did not get a date for stream %s '+
' not advancing bookmark',
tap_stream_id)
elif not current_bookmark or date > current_bookmark:
LOGGER.info('Bookmark for stream %s is currently %s, ' +
'advancing to %s',
tap_stream_id, current_bookmark, date)
state = singer.write_bookmark(state, tap_stream_id, bookmark_key, str(date))
else:
LOGGER.info('Bookmark for stream %s is currently %s ' +
'not changing to to %s',
tap_stream_id, current_bookmark, date)
return state
评论列表
文章目录