An on-demand transformation is a feature function that is used to compute an on-demand feature. It is run both in an online inference pipeline and in a feature pipeline. In the online inference pipeline, the on-demand feature function takes as input data only available at request-time (it may also use pre-computed features from the feature store), while in the feature pipeline the on-demand feature function takes as input historical data.
Here is a short snippet showcasing an on-demand transformation that calculates the time since the last user interaction in an online inference pipeline:
This example demonstrates a simple on-demand transformation (feature function) that computes the time since the last user interaction based on the current time and the timestamp of the last interaction (a lag feature).
This feature function can also be applied both in the feature pipeline using historical data, as shown below: