LifetimeWindow
This capability requires Online Compaction. Online compaction and Lifetime Windows are in Private Preview and have limitations that will be resolved in future Tecton releases. See Limitations & Requirements for more details. This is currently available for Spark-based Feature Views -- support for Rift is coming soon.
Summary​
This class describes a LifetimeWindow that is applied in an Aggregation within a Batch or Stream Feature View. Lifetime Windows are useful for expressing a feature like "user transaction average since Jan 1, 2000." See this page more information on Lifetime Windows and other Aggregation Windows.
Note that when using a LifetimeWindow
, the Batch or Stream Feature View must
have compaction_enabled=True
and must set lifetime_start_time
if
materialization is enabled.
Description​
Tecton Aggregations are applied over a specified time window using the
time_window
parameter. Use LifetimeWindow
to create an Aggregation over a
window that continuously expands.
Example​
from tecton import batch_feature_view, FilteredSource, Aggregate, LifetimeWindow
from tecton.types import Field, Float32
@batch_feature_view(
sources=[transactions],
mode="spark_sql",
entities=[user],
aggregation_interval=timedelta(days=1),
compaction_enabled=True,
lifetime_start_time=datetime(2000, 1, 1),
timestamp_field="timestamp",
features=[Aggregate(input_column=Field("amount", Float32), function="mean", time_window=LifetimeWindow())],
)
def user_average_transaction_amount(transactions):
return f"SELECT user_id, timestamp, amount FROM {transactions}"
The start time of this window is Jan 1, 2000 (as specified by
lifetime_start_time
). The end time of this window will be the most recent
aggregation interval as of an incoming online feature request or training event
timestamp (during offline feature retrieval).