ds_provider_unimicro_py_lib.utils.incremental

File: incremental.py Region: ds_provider_unimicro_py_lib/utils/incremental

Helpers for incremental loading: watermark detection, incremental filters and checkpoints.

Attributes

logger

TIMESTAMP_COLUMNS

Functions

greatest_incremental_value(→ str | None)

Determine the greatest incremental value (last modified date) from the fetched records.

build_incremental_filter(→ str)

Build the provider-specific incremental filter.

build_checkpoint(→ dict[str, Any])

Build a checkpoint dictionary to track the last successfully read page.

Module Contents

ds_provider_unimicro_py_lib.utils.incremental.logger
ds_provider_unimicro_py_lib.utils.incremental.TIMESTAMP_COLUMNS = ('CreatedAt', 'UpdatedAt')
ds_provider_unimicro_py_lib.utils.incremental.greatest_incremental_value(records: pandas.DataFrame) → str | None[source]

Determine the greatest incremental value (last modified date) from the fetched records.

Parameters:

records (pd.DataFrame) – The dataframe of all fetched records.

Returns:

The greatest ISO-8601 timestamp found in CreatedAt/UpdatedAt, or None if there are no valid timestamps.

Return type:

str | None

ds_provider_unimicro_py_lib.utils.incremental.build_incremental_filter(last_modified_date: str) → str[source]

Build the provider-specific incremental filter.

Parameters:

last_modified_date – Watermark; only records created or updated after it are selected.

Returns:

Filter clause matching records with CreatedAt or UpdatedAt after the watermark.

Return type:

str

ds_provider_unimicro_py_lib.utils.incremental.build_checkpoint(last_loaded_records: int | None, last_modified_date: str | None) → dict[str, Any][source]

Build a checkpoint dictionary to track the last successfully read page.

Parameters:
  • last_loaded_records (int | None) – The number of records that were successfully read (records to skip).

  • last_modified_date (str | None) – The last modified date to include in the checkpoint.

Returns:

A checkpoint dictionary containing the incremental and pagination values.

Return type:

dict[str, Any]