ds_provider_unimicro_py_lib.utils.incremental ============================================= .. py:module:: ds_provider_unimicro_py_lib.utils.incremental .. autoapi-nested-parse:: **File:** ``incremental.py`` **Region:** ``ds_provider_unimicro_py_lib/utils/incremental`` Helpers for incremental loading: watermark detection, incremental filters and checkpoints. Attributes ---------- .. autoapisummary:: ds_provider_unimicro_py_lib.utils.incremental.logger ds_provider_unimicro_py_lib.utils.incremental.TIMESTAMP_COLUMNS Functions --------- .. autoapisummary:: ds_provider_unimicro_py_lib.utils.incremental.greatest_incremental_value ds_provider_unimicro_py_lib.utils.incremental.build_incremental_filter ds_provider_unimicro_py_lib.utils.incremental.build_checkpoint Module Contents --------------- .. py:data:: logger .. py:data:: TIMESTAMP_COLUMNS :value: ('CreatedAt', 'UpdatedAt') .. py:function:: greatest_incremental_value(records: pandas.DataFrame) -> str | None Determine the greatest incremental value (last modified date) from the fetched records. :param records: The dataframe of all fetched records. :type records: pd.DataFrame :returns: The greatest ISO-8601 timestamp found in ``CreatedAt``/``UpdatedAt``, or None if there are no valid timestamps. :rtype: str | None .. py:function:: build_incremental_filter(last_modified_date: str) -> str Build the provider-specific incremental filter. :param 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. :rtype: str .. py:function:: build_checkpoint(last_loaded_records: int | None, last_modified_date: str | None) -> dict[str, Any] Build a checkpoint dictionary to track the last successfully read page. :param last_loaded_records: The number of records that were successfully read (records to skip). :type last_loaded_records: int | None :param last_modified_date: The last modified date to include in the checkpoint. :type last_modified_date: str | None :returns: A checkpoint dictionary containing the incremental and pagination values. :rtype: dict[str, Any]