Connector Improvement: Cloud functions hasMore behavior should not have to preserve state in the function
AnsweredWhen a cloud function (I'm working in Azure today) returns hasMore=true, the bookmark is not updated by Fivetran, so the same state is sent back to the function on the subsequent call. This implies that the function has to somehow keep track of the state between calls. It would be better if the function could just set hasMore=true, return the proper bookmark as the state, then the connector would send a new request with the updated state.
-
Official comment
Hi! Please see our documentation regarding the `state` atttribute:
https://fivetran.com/docs/functions#requestformat
Your function is required to update `state` with whatever the next state should be on the subsequent function call. You are calling this your "bookmark," you can set `state` to whatever value(s) you need to be able to pick up where you left off on the previous run of the function. So for example, as part of your response,
{ "state": { "bookmark": "bookmark_value" }, "insert": { /* insertions here */ }, "delete": { /* deletions here */ }, "schema" : { /* schema definition here */ }, "hasMore" : true }Keep in mind, if there is an error on the Fivetran side, we may need to call your function with the previously known good state. Your function should be able to pick up from whatever state is passed to it. However, this should be a very infrequent occurrence.
-
It would be awesome if yall could clarify this behavior in the documentation. It's not obvious (at least to me) that the `state` object will persist between calls when using `hasMore`.
-
I agree with Kaoru. The documentation is not very clear.
-
Hi Ambex - we added this disclaimer to the documentation:
hasMoreis a boolean indicator for Fivetran to make a follow-up call to fetch the next set of data. Fivetran will keep making calls whilehasMore = trueuntil it receiveshasMore = false. In either case, your response should return an updated state to checkpoint the data fetched in that request and avoid an infinite loop.Is it still unclear?
Please sign in to leave a comment.
Comments
4 comments