Serve Feature Views
This feature is in Public Preview. Workspace admins can control access to this feature from the Previews page. See Manage Databricks previews.
You can serve Feature Views online in two ways:
- Model serving: Deploy a model that was trained on Feature Views. The endpoint looks up or computes feature values automatically, using the lineage tracked when the model was logged. Use this to serve model predictions.
- Feature Serving: Deploy a
FeatureSpecthat references Feature Views directly, without a model. The endpoint returns the requested feature outputs. Use this when an application needs feature values rather than model predictions.
Both approaches support precomputed and on-demand features. Table- and stream-backed leaf features must have supported online materializations. RequestSource supplies values from the request, and CustomUDF computes features on demand. For a CustomUDF with FeatureViewSource, serving resolves upstream dependencies and evaluates the feature dependency graph automatically.
Register the requested features and all of their transitive upstream features in Unity Catalog. Materialize only the table- and stream-backed leaves, not the request-time or derived CustomUDF features.
Permissions
To serve a feature, the principal that creates the model serving endpoint must have SELECT on the Unity Catalog table that backs the materialized feature. Online lookups read directly from the materialized table, so table-level SELECT is what grants serving access. For the privilege description, see SELECT.
Because a materialized table can hold more than one feature, granting SELECT on it grants access to every feature in that table, not only the one you intend to serve. Before you grant serving access, confirm that every feature sharing the table can be shared with the principal. To limit exposure, materialize sensitive features separately.
To grant this access without resolving tables by hand, use FeatureEngineeringClient.grant_feature_serving_access. Given a model or feature spec, it resolves each feature to its online table, grants SELECT (along with USE CATALOG and USE SCHEMA) on those tables to the principals you specify, and returns a report of each table and the additional features the grant exposes. Pass dry_run=True to preview the report before granting.
from databricks.feature_engineering import FeatureEngineeringClient
fe = FeatureEngineeringClient()
# Preview the tables and the features each grant would expose.
report = fe.grant_feature_serving_access(
grant_to=["serving-principal@example.com"],
model_uri="models:/main.ecommerce.fraud_model/1",
dry_run=True,
)
print(report)
# Grant SELECT on the resolved online tables.
fe.grant_feature_serving_access(
grant_to=["serving-principal@example.com"],
model_uri="models:/main.ecommerce.fraud_model/1",
)
Deploy a model serving endpoint
Use an existing model serving endpoint, or use the Databricks SDK to create a new one. The model must be registered in Unity Catalog.
If a CustomUDF uses a user-defined function (UDF) that imports Python packages, pass them explicitly through extra_pip_requirements when you call log_model. See Custom UDF dependencies.
The following code shows how to create a new model serving endpoint. For more information, see Create custom model serving endpoints.
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import EndpointCoreConfigInput, ServedEntityInput
w = WorkspaceClient()
endpoint_name = "fraud-detection-endpoint"
model_name = "main.ecommerce.fraud_model"
w.serving_endpoints.create(
name=endpoint_name,
config=EndpointCoreConfigInput(
name=endpoint_name,
served_entities=[
ServedEntityInput(
entity_name=model_name,
entity_version=1,
max_provisioned_concurrency=4,
min_provisioned_concurrency=0,
)
],
),
)
Query the endpoint
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
response = w.serving_endpoints.query(
name="fraud-detection-endpoint",
dataframe_records=[
{"user_id": "user_123", "transaction_time": "2026-03-01T12:00:00"},
],
)
Query the endpoint with RequestSource features
If the model was trained with RequestSource features, the request payload must also include all RequestSource columns. These columns were added to the MLflow model signature during log_model, so the endpoint's API schema reflects the required request fields.
response = w.serving_endpoints.query(
name="fraud-detection-endpoint",
dataframe_records=[
{
"user_id": "user_123",
"transaction_time": "2026-03-01T12:00:00",
"transaction_amount": 275.30, # RequestSource column
"vendor_id": "v_42", # RequestSource column (also used as entity key)
},
],
)
Entity keys are used for looking up table-backed features from the online store. A ColumnSelection feature can pass a RequestSource value through to the model. A CustomUDF feature transforms its request inputs before the model uses the result.
You can also use curl:
curl -X POST "https://<workspace>.cloud.databricks.com/serving-endpoints/<endpoint>/invocations" \
-H "Authorization: Bearer $DATABRICKS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"dataframe_records": [
{
"user_id": "user_123",
"transaction_time": "2026-03-01T12:00:00",
"transaction_amount": 275.30,
"vendor_id": "v_42"
}
]
}'
Serve features with a FeatureSpec
To serve Feature Views without a model, create a FeatureSpec that references the features and deploy it to a Feature Serving endpoint. The endpoint returns only the feature outputs requested in the spec. It computes intermediate values automatically without returning them unless you also request those features.
Register all of the features in Unity Catalog and create supported online materializations for the table- and stream-backed leaves before you create the endpoint.
A FeatureSpec that contains Feature Views cannot also contain FeatureLookup or FeatureFunction definitions. Feature Views cannot be mixed with those definitions in the same FeatureSpec.
from databricks.feature_engineering import FeatureEngineeringClient
from databricks.feature_engineering.entities.feature_serving_endpoint import (
EndpointCoreConfig,
ServedEntity,
)
fe = FeatureEngineeringClient()
# 1. Retrieve a registered Feature View
agg_feature = fe.get_feature(full_name="main.ecommerce.amount_sum_sliding_7d_1d")
# 2. Create a FeatureSpec that includes the Feature View
feature_spec_name = "main.ecommerce.transaction_feature_spec"
fe.create_feature_spec(name=feature_spec_name, features=[agg_feature])
# 3. Deploy a Feature Serving endpoint backed by the FeatureSpec
fe.create_feature_serving_endpoint(
name="transaction-features",
config=EndpointCoreConfig(
served_entities=ServedEntity(
feature_spec_name=feature_spec_name,
workload_size="Small",
scale_to_zero_enabled=True,
)
),
)
Query the endpoint with the entity keys used to look up the materialized features:
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
response = w.serving_endpoints.query(
name="transaction-features",
dataframe_records=[{"user_id": "user_123"}],
)
For more about Feature Serving endpoints see Feature Serving endpoints.
Serve CustomUDF features and their dependencies
This example serves the transaction and margin features defined in the CustomUDF and FeatureViewSource examples. Use databricks-feature-engineering version 0.18.0 or above for these Feature Views APIs.
log_transaction_amountappliesmain.ecommerce.log_amount_udfto the request'stransaction_amountvalue using NumPy.marginusesFeatureViewSourceto compute a margin fromrevenue_sum_7dandcost_sum_7d. These upstream features usecustomer_idas their entity key andevent_timeas their timeseries column.
Register both output features and every upstream feature before creating the spec. For this example, online-materialize only the revenue_sum_7d and cost_sum_7d leaves. Serving looks up their values and computes margin for each request.
Retrieve the registered Feature objects and pass them to create_feature_spec. Declare NumPy for online execution even if it is already listed in the UDF's ENVIRONMENT clause:
from databricks.feature_engineering import FeatureEngineeringClient
fe = FeatureEngineeringClient()
log_transaction_amount = fe.get_feature(
full_name="main.ecommerce.log_transaction_amount"
)
margin = fe.get_feature(full_name="main.ecommerce.margin")
fe.create_feature_spec(
name="main.ecommerce.derived_transaction_features",
features=[log_transaction_amount, margin],
extra_pip_requirements=["numpy==1.26.4"],
)
Follow the endpoint creation steps above with feature_spec_name="main.ecommerce.derived_transaction_features" and an endpoint name such as derived-transaction-features. After the endpoint is ready, supply the lookup key and request-time value:
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
response = w.serving_endpoints.query(
name="derived-transaction-features",
dataframe_records=[
{"customer_id": "customer_123", "transaction_amount": 99.0},
],
)
The response contains only the requested log_transaction_amount and margin outputs, not the intermediate revenue and cost values. For dependency formats, wheel permissions, and installation troubleshooting, see Add Python dependencies.