<@U04S8PLJWMT> How can I configure an incremental ...
# ask-ai
b
@kapa.ai How can I configure an incremental sync on a customer connector in the web UI Builder when there is no cursor field in the data? I would like to configure a start date, set a step value of P1D, and pass each date value in a query parameter called start_date and end_date. It will make an API call for each start_date and end_window until now(), and then the state will be stored so when the connection runs the next day, it only calls since the stream_state state that is yesterday.
✅ 1
k
To configure an incremental sync in the Airbyte Connector Builder UI when your data does not contain a cursor field, you can still achieve your goal by leveraging the time window partitioning features. Here’s how you can set it up: 1. Enable Incremental Sync: In the Builder UI, enable the "Incremental sync" option for your stream. 2. Cursor Field: Since your data does not have a cursor field, you can still configure the sync to use the time window as the state. In the UI, you may need to select a dummy or synthetic cursor field, or leave it blank if allowed. However, the documentation and tutorials assume a cursor field is present, so this may be a limitation if the UI enforces a cursor field selection. 3. Start and End Datetime: - Set the "Start datetime" to "User input" or an interpolated value (e.g.,
{{ config['start_time'] }}
) so the user can specify the initial date. - Set the "End datetime" to "Now" (e.g.,
{{ now_utc().strftime('%Y-%m-%d') }}
) to always sync up to the current date. 4. Step Value: In the "Advanced" section, enable "Split up interval" and set the "Step" to
P1D
to partition the sync into daily intervals. 5. Inject Dates into Request: - Configure the "Inject start/end time into outgoing HTTP request" options: - Set the start time to be injected as a query parameter named
start_date
. - Set the end time to be injected as a query parameter named
end_date
. 6. State Management: Airbyte will store the last synced interval (the end date of the last successful partition) as the state. On the next sync, it will resume from this date, ensuring only new data is fetched. Example Configuration Steps (based on the tutorials for similar use cases): - Enable "Incremental sync". - Set "Start datetime" to user input. - Set "End datetime" to now. - Set "Step" to
P1D
. - Inject
start_date
and
end_date
as query parameters. - (If required) Set a dummy cursor field or leave blank if the UI allows. Note: The documentation and tutorials assume the presence of a cursor field in the data, which is used to track state. If your API does not return a cursor field, you may need to rely on the partition window itself as the state, and Airbyte will store the last end date as the state. This approach is described in the context of APIs where the date is injected into the path or parameters, and the state is managed by the last interval synced, not by a field in the data itself. See the exchange rates API tutorial for a similar pattern, where the date is injected into the path and no cursor field is present in the data itself [Adding incremental reads](https://docs.airbyte.com/platform/1.8/connector-development/connector-builder-ui/tutorial#adding-incremental-reads). If the UI enforces a cursor field, you may need to create a synthetic field in the response or use a transformation to add the interval date to each record, so Airbyte can track state. References: - [Adding incremental reads (tutorial)](https://docs.airbyte.com/platform/1.8/connector-development/connector-builder-ui/tutorial#adding-incremental-reads) - [Incremental sync configuration](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync) - [DatetimeBasedCursor and partitioning](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/incremental-syncs#datetimebasedcursor) If you encounter a limitation in the UI regarding the cursor field, you may need to adjust your API response or use a transformation as a workaround.
b
That's helpful, thanks. How can I create a synthetic field in the response that enables Airbyte to track state?
@kapa.ai How can I create a synthetic field in the response that enables Airbyte to track state?
k
A message from kapa.ai
To create a synthetic field in the response that enables Airbyte to track state, you would typically add a field to each record that represents the cursor value (such as a timestamp) during the data extraction or transformation process. This synthetic field can then be used as the cursor field for incremental syncs. However, based on the provided knowledge sources, there is no explicit documentation or example that describes how to programmatically add a synthetic cursor field to the response within the Airbyte Connector Builder UI. The documentation does mention that if the cursor field is nested, you can use an "Add Field" transformation to move it to the top level, but it does not cover generating a new synthetic field if none exists in the source data [Incremental sync](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/incremental-sync). In the Airbyte Python CDK, it is possible to add a synthetic field in the
parse_response
method, but this approach is not described for the Connector Builder UI in the available documentation. The forum discussions also suggest that while you can add a synthetic timestamp in code, this is not natively supported in the UI and may require custom code [Forum: Selecting a good cursor field when there aren't any](https://discuss.airbyte.io/t/471). Summary: I'm sorry, but the knowledge sources do not provide explicit instructions for creating a synthetic field in the response within the Airbyte Connector Builder UI. This may require custom connector development outside of the UI, or using transformations if your cursor field is nested but not if it is entirely missing.
j
@Brenden Goetz That answer gets you most of the way there, you would just use an Add Field Transformation with a Jinja merge as the value, like this:
{{ now_utc().strftime('%Y-%m-%dT%H:%M:%SZ') }}
I typically call a field like this something like
date_last_loaded
. You may need to adjust the output date format a bit depending on your needs. And you can always use the Lookback Window to add some wiggle room for timing issues from when they sync was running (basically just re-pulling an extra hour or day or whatever you need). I use this on a custom forked version of the Kit (formerly ConvertKit) connector to handle a scenario where their stream has an
updated_after
filter but no updated_at value in the data. (still waiting to get this merged back to the main one, but eventually it will be)
In cases where the API doesn't have an option to filter by last updated date (or similar) but can return the results in descending order by that field, the
API Time Filtering Capabilities
>
No filter (data feed)
option can be helpful as well.
b
Thanks for taking a look at this! I thought I saw in an older thread that that "Add Field Transformation" couldn't be used to capture
stream_state
via the cursor field... But you're right, it can 🙂 I see it working in the Builder tests... Just working through the HTTP API Budget config to deal with rate limits now!
🙌 1