Calculation Features
This feature is currently in Private Preview.
- Only available for Realtime Feature Views.
- Set of supported SQL functions is limited and is actively being expanded. See SQL Expression Reference below for details.
- Please reach out to Tecton Support for questions and feedback!
Overview​
A Calculation
is a Feature Type which allows you to define performant
transformations on your source data using a simple SQL-like syntax. By avoiding
the overhead of executing a Python function, Calculation
features can be an
efficient alternative for Feature Views that don't require the expressiveness of
a python
or pandas
mode transformation.
Calculation Features are the recommended path for
simple operations such as setting default values,
simple arithmetic operations, and DATEDIFF
s.
Usage​
Calculation Features are defined using SQL-like expressions in the expr
field
of a Calculation
object. Unlike python
and pandas
mode Realtime Feature
Views which use a decorator pattern, Calculation Features are defined by
directly instantiating a RealtimeFeatureView
object with one or more
Calculation
features.
Feature Views using Calculation
Features can not use a transformation
function.
transaction_analysis = RealtimeFeatureView(
sources=[context, user_metrics],
features=[
Calculation(name="transaction_z_score", expr="(context.amount - user_metrics.mean) / user_metrics.stddev"),
Calculation(
name="is_amount_above_threshold",
expr="context.amount > user_metrics.threshold",
),
],
)
Type System​
Calculation Features use Tecton's native type system for validating inputs and output types. When writing expressions, types are automatically inferred from your input features and operations.
Invalid type combinations will raise errors during feature validation rather than runtime:
# This will fail validation - can't add string and int
Calculation(name="invalid", expr="<string_field> + <int_field>")
SQL Expression Reference​
A full list of supported SQL functionality can be found in the SDK Reference.