Skip to main content
Version: 0.9

LifetimeWindow

Private Preview

This capability requires Data Compaction. 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, Aggregation, LifetimeWindow


@batch_feature_view(
sources=[FilteredSource(transactions)],
mode="spark_sql",
entities=[user],
aggregation_interval=timedelta(days=1),
compaction_enabled=True,
lifetime_start_time=datetime(2000, 1, 1),
aggregations=[Aggregation(column="amount", 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).

Was this page helpful?

🧠 Hi! Ask me anything about Tecton!

Floating button icon