<@U04S8PLJWMT> how to ensure that connector always...
# ask-ai
m
@kapa.ai how to ensure that connector always does hourly intervals when pulling data from a data source via yaml configuration?
k
To ensure that a connector always pulls data in hourly intervals via YAML configuration in Airbyte, you need to configure the incremental sync settings to split the time range into 1-hour steps. This is done by setting the "Step" and "Cursor Granularity" to an ISO 8601 duration representing one hour (
PT1H
). Here’s how you can do it: 1. Enable Incremental Sync for your stream. 2. Set the Cursor Field to the field in your records that represents the timestamp. 3. Set the Cursor Field Datetime Format to match your data. 4. Enable "Split up interval" in the advanced incremental sync settings. 5. Set "Step" to
PT1H
to make the connector request data in 1-hour intervals. 6. Set "Cursor granularity" to
PT1H
to indicate the API supports hourly increments. Example configuration in YAML (conceptual, as the exact structure may vary by connector):
Copy code
yaml incremental_sync:   cursor_field: "your_timestamp_field"   cursor_field_datetime_format: "%Y-%m-%dT%H:%M:%SZ"   split_up_interval: true   step: "PT1H"   cursor_granularity: "PT1H"
This setup ensures that during each sync, the connector will fetch data in hourly chunks, never requesting more than one hour of data per API call. This is useful for APIs that require or perform best with hourly data windows, or to minimize data loss in case of failures. For more details, see the advanced settings for incremental sync in the Airbyte documentation: [Incremental sync - Advanced settings](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/incremental-sync#advanced-settings). The ISO 8601 duration format for one hour is
PT1H
as shown in the documentation for the
Rate
object as well [YAML Reference - Rate](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/Rate).
m
@kapa.ai looks like the start and end time is the same in the out going request if I set lookback window 1 h, step 1h and cursor granularity 1 hour.
k
A message from kapa.ai
If you set the lookback window to 1 hour (
PT1H
), step to 1 hour (
PT1H
), and cursor granularity to 1 hour (
PT1H
), the connector will partition the time range into 1-hour intervals. However, if the start and end time in the outgoing request are the same, this could indicate a misconfiguration or a misunderstanding of how these parameters interact. According to the documentation, the lookback window extends the start time backwards by the specified duration, so you fetch data from before the last known cursor position. The step determines the size of each interval, and cursor granularity ensures there is no overlap between intervals. For each interval, the start and end times should be one hour apart, not the same. Here’s how it should work: - lookback_window: PT1H — Each sync will start 1 hour before the last cursor value. - step: PT1H — Each request covers a 1-hour window. - cursor_granularity: PT1H — Ensures intervals do not overlap by more than 1 hour. If you observe that the outgoing request has the same start and end time, this is not the expected behavior. The documentation shows that, for example, with a step of 1 day and granularity of 1 second, the intervals are non-overlapping and cover the full range between start and end times. The same logic applies for 1-hour intervals: each request should have a start and end time 1 hour apart, not equal ([Incremental Syncs - DatetimeBasedCursor](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/incremental-syncs)). If you are seeing identical start and end times, it may be a bug or an edge case in your configuration. Double-check that your cursor field and datetime formats are set correctly, and that your data source supports the requested granularity. If the issue persists, it may be worth reporting as a bug, as seen in [this related issue](https://github.com/airbytehq/airbyte/issues/27010), where repeated query parameters caused unexpected behavior. Summary: With lookback window, step, and cursor granularity all set to 1 hour, the outgoing requests should have start and end times 1 hour apart. If they are the same, this is not expected and may indicate a configuration or implementation issue. The knowledge sources do not provide a reason for this specific behavior, so further investigation may be needed.
m
@kapa.ai how to make the end datetime rounded to the near hour minus 1 second:
Copy code
{{ now_utc().replace(minute=0, second=0, microsecond=0).strftime('%Y-%m-%dT%H:%M:%SZ') }}
k
A message from kapa.ai
To round the end datetime to the nearest hour minus 1 second in Airbyte's YAML configuration, you would typically use a Jinja expression. However, the built-in Jinja macros and functions documented in Airbyte (such as
now_utc()
) do not support direct arithmetic operations like subtracting one second after rounding to the hour. The documented usage is:
Copy code
jinja {{ now_utc().replace(minute=0, second=0, microsecond=0).strftime('%Y-%m-%dT%H:%M:%SZ') }}
This will round the current UTC time down to the nearest hour, but it does not subtract one second. The knowledge sources do not mention a built-in way to subtract one second from a datetime in Jinja within Airbyte's configuration. There is no documented macro or function for datetime arithmetic like
timedelta
in the provided references. Therefore, you cannot directly achieve "nearest hour minus 1 second" using only the documented Airbyte YAML/Jinja features. Summary: I'm sorry, but the knowledge sources do not contain information about subtracting one second from a rounded hour using Jinja in Airbyte YAML configuration. You can round to the nearest hour as shown above, but subtracting one second is not supported by the documented macros or functions [Interpolation macros](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/reference#macros).