来源与时点
原能力
保存来源、发布时间、实际可得时间和修订。重复转载归到同一来源链。(细化版 p.4–5)
首选项目
dlt(Apache-2.0(开源库))。 dlt
匹配范围
增量采集与游标保存分次读取结果。
源码
dlt · class Incremental(
dlt/extract/incremental/__init__.py · 99–112 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
class Incremental(
ItemTransform[TDataItem, IncrementalCustomMetrics], BaseConfiguration, Generic[TCursorValue]
):
"""Adds incremental extraction for a resource by storing a cursor value in persistent state.
The cursor could for example be a timestamp for when the record was created and you can use this to load only
new records created since the last run of the pipeline.
To use this the resource function should have an argument either type annotated with `Incremental` or a default `Incremental` instance.
For example:
>>> @dlt.resource(primary_key='id')
>>> def some_data(created_at=dlt.sources.incremental('created_at', '2023-01-01T00:00:00Z'):
>>> yield from request_data(created_after=created_at.last_value)
实现与验收要点
分别记录发布、首次实际获得、入库和修订时点。