What you will be able to do
- Call fe.score_batch with a DataFrame of lookup keys and predict the columns it returns
- Explain why score_batch fails on a model logged with a plain MLflow flavor or used with the wrong client
- Override a packaged feature and supply extra non-feature-store columns at scoring time
- Prepare a scoring DataFrame for a time series feature table and handle missing lookup keys
- Choose between score_batch, mlflow.pyfunc and Model Serving for a feature store model
Key concept
Automatic feature lookup at scoring time — A model logged through the feature store client carries the list of features it was trained on and the tables and keys they came from. When it scores, it uses that list to fetch the features itself, so the caller only has to send the primary keys.
1.Why a feature store model needs only keys to score
Scoring a model that was trained on feature table data raises one practical problem: the new records do not have the derived feature columns. A batch of tomorrow's orders has a customer_id and a product_id, not total_purchases_30d. Without a feature store, you would rebuild those columns by hand by joining the feature tables onto the batch before calling predict(). That is the same join logic written a second time, and it can drift from the version used in training.
The feature store removes that second join. When you train with a training set and log the model through the client, the model keeps a record of each feature it used and which table and key each one came from. This is covered in fe.log_model: packaging feature metadata with the model, and it is the reason scoring needs only the primary keys: the model already knows where everything else lives. In batch, it reads the values from the offline Delta feature tables and joins them onto your rows before the model runs.
That record exists only if the model went through the feature store client's log_model. A scikit-learn model trained on a TrainingSet.load_df() DataFrame but logged with mlflow.sklearn.log_model is just a scikit-learn model. It has the same weights but no feature references. Give score_batch a keys-only DataFrame for that model and the call fails, because nothing tells it which tables to join. Training on feature store data does not attach the metadata. Logging with the client does.
The client also has to match. Feature tables in Unity Catalog go through FeatureEngineeringClient (fe), and the legacy Workspace Feature Store goes through FeatureStoreClient (fs). This split is explained in FeatureEngineeringClient vs legacy FeatureStoreClient. Every documented example pairs them the same way: fe.log_model is scored with fe.score_batch, and fs.log_model with fs.score_batch. Call score_batch on the type of client that logged the model.
Checkpoint 1 of 9· Check yourself
A data scientist builds a training set with fe.create_training_set, trains a scikit-learn model on training_set.load_df(), and logs it with mlflow.sklearn.log_model. Later they call fe.score_batch on that model with a batch DataFrame that has only customer_id and product_id. What happens?
Only the feature store client's log_model packages the feature references with the model. A model logged with mlflow.sklearn.log_model is a plain scikit-learn model with no record of tables or keys, so a keys-only DataFrame can't be scored. Training on feature store data does not attach that record.
“To package a model with feature metadata, use FeatureEngineeringClient.log_model (for Feature Engineering in Unity Catalog) or FeatureStoreClient.log_model (for Workspace Feature Store).”Source: docs.databricks.com
Checkpoint 2 of 9· Exam question
A team trained a scikit-learn model using a DataFrame produced by TrainingSet.load_df(), but at the end of the notebook they logged it using mlflow.sklearn.log_model(model, "model") instead of the Feature Engineering client's logging method. When they later call fe.score_batch() against a batch DataFrame containing only lookup keys, the call fails. What is the most likely cause?
Correct answer: A — The model was not logged with FeatureEngineeringClient.log_model(), so it was not packaged with the feature_spec.yaml artifact that score_batch() needs to know which feature tables and lookup keys to join.
- A. Only
FeatureEngineeringClient.log_model()packages the trained model with the feature lookup specification that tellsscore_batch()which feature tables and keys to join. Logging with the genericmlflow.sklearn.log_model()skips that packaging step, so scoring against lookup keys alone has nothing to resolve the feature joins with. - B. A
predictioncolumn is reserved for the output ofscore_batch()and is never required as an input placeholder, so this is not why the call fails; in fact supplying one would conflict with the reserved output name. - C. The scenario gives no indication the feature table was removed, and a missing table would typically raise a distinct table-not-found error rather than the failure caused by skipping the feature-aware logging step.
- D. A primary key type mismatch is a plausible but separate failure mode that would surface as a join or type error, not the root cause described here, where the model itself was never packaged with feature lookup metadata.
2.Calling score_batch and reading its output
score_batch takes two arguments: a model_uri that points to the logged or registered model, and df, a Spark DataFrame with the lookup keys. It reads the feature metadata stored with the model, fetches each required feature from its table using the keys in df, scores the model, and returns one DataFrame. That DataFrame keeps all of your input columns, adds a column for each looked-up feature, and adds a prediction column.
fe = FeatureEngineeringClient()
# batch_df has columns 'customer_id' and 'product_id'
predictions = fe.score_batch(
model_uri=model_uri,
df=batch_df
)
# The 'predictions' DataFrame has these columns:
# 'customer_id', 'product_id', 'total_purchases_30d', 'category', 'prediction'Because the feature columns stay in the output, you can audit a batch afterwards: a strange prediction can be traced to the exact feature values that produced it, in the same row. Some approaches look similar but are not the scoring path. You could join the feature table with Spark SQL or pandas.merge and then call predict(), but that rebuilds the join by hand. You could call create_training_set again on the batch, but that API builds a training dataset. It is not a scoring call. score_batch is the method that turns keys into predictions.
Checkpoint 3 of 9· Fill the gap
batch_df holds only the lookup keys for a model logged with fe.log_model. Which method fills the blank so the call returns the looked-up features plus a prediction column?
fe = FeatureEngineeringClient()
# batch_df has columns 'customer_id' and 'product_id'
predictions = fe. ? (
model_uri=model_uri,
df=batch_df
)
# The 'predictions' DataFrame has these columns:
# 'customer_id', 'product_id', 'total_purchases_30d', 'category', 'prediction'score_batch reads the feature metadata packaged with the model and uses the keys in df to fetch each feature from its table. It then scores the model and returns the input columns, the feature columns and a prediction column. create_training_set builds a training dataset, not predictions, and log_model packages the model.
Source: docs.databricks.comCheckpoint 4 of 9· Exam question
A ML engineer at a retail company trained and logged a model using FeatureEngineeringClient.log_model(), embedding feature lookup metadata from a Unity Catalog feature table. Now they need to generate predictions for a new batch of records that lack the derived feature columns used during training. Which approach lets them generate predictions without manually joining the feature table into the batch DataFrame?
Correct answer: A — Call fe.score_batch(model_uri=..., df=batch_df) where batch_df contains the primary key columns needed to look up the feature table rows, so the API retrieves and joins the missing features automatically.
- A.
score_batch()reads the feature metadata packaged with the model at logging time and uses the primary key columns present in the input DataFrame to look up and join any missing features from the feature table before scoring. This removes the need to write a manual join or reload the feature table separately. - B. Loading the model with
mlflow.pyfunc.load_modelbypasses the packaged feature metadata entirely, so this approach requires the exact manual join logic it was meant to avoid, and it is more error-prone than letting the scoring API resolve the lookups. - C. Converting the feature table to pandas and merging locally discards the benefit of the feature store's managed lookup and does not scale for large feature tables, defeating the purpose of using a feature store for scoring.
- D.
create_training_set()andload_df()are part of the training workflow, not the scoring workflow, and calling them against a batch of new records to score is not how inference-time feature lookup is performed.
3.Overriding features and adding columns from outside the store
A column in the scoring DataFrame that has the same name as a packaged feature replaces the lookup for that feature. score_batch does not raise a duplicate-column error and does not overwrite your values. It uses the values you supplied and fetches only the features that are still missing. Suppose a model was packaged with account_creation_date and num_lifetime_purchases. If you score a DataFrame with customer_id and account_creation_date, only num_lifetime_purchases is read from the feature table.
# batch_df has columns ['customer_id', 'account_creation_date']
predictions = fe.score_batch(
model_uri='models:/ban_prediction_model/1',
df=batch_df
)Overrides are useful when a fresher value exists than the one in the table, such as a velocity computed by a streaming job seconds ago. The risk runs the other way. A column left over in the batch with a feature's name will quietly replace the table value, and nothing warns you.
Features that never came from the store follow a stricter rule. A model can be trained on a mix of feature table columns and ordinary columns, for example a browser column passed through create_training_set without being excluded. The feature store has no table to read browser from, so the scoring DataFrame has to include it next to the keys.
| Column kind | Example | At score_batch time |
|---|---|---|
| Lookup key | customer_id, product_id | Required; used to fetch packaged features |
| Packaged feature, not supplied | num_lifetime_purchases | Looked up from the feature table |
| Packaged feature, supplied | account_creation_date | Your value is used; no lookup for it |
| Non-feature-store training column | browser | Required; there is no table to read it from |
Checkpoint 5 of 9· Check yourself
Before calling fe.score_batch, an engineer adds a fresh account_creation_date column to batch_df, next to customer_id. The model was logged with fe.log_model and packaged with account_creation_date and num_lifetime_purchases. How does score_batch treat the batch?
When a column has the same name as a packaged feature, it replaces the lookup for that feature. score_batch uses the values you supplied and reads only the features that are still missing from the table. There is no error and no overwrite.
“the API looks up only the num_lifetime_purchases feature from Feature Store and uses the provided custom account_creation_date column values for model scoring”Source: docs.databricks.com
Checkpoint 6 of 9· Check yourself
A model was trained on total_purchases_30d, looked up by customer_id, and on a browser column that was passed through create_training_set and not excluded. It was logged with fe.log_model. Which batch DataFrame is the minimum that fe.score_batch can score?
total_purchases_30d is a packaged feature, so it is looked up from the table using customer_id. browser did not come from a feature table, so there is no table to read it from and the scoring DataFrame has to include it.
“At inference, the DataFrame used in FeatureStoreClient.score_batch must include the browser column.”Source: docs.databricks.com
Checkpoint 7 of 9· Exam question
A fraud detection model was trained using features from a Unity Catalog feature table, including a transaction_velocity feature. Before calling fe.score_batch(), an engineer added their own precomputed transaction_velocity column to the batch DataFrame using a faster streaming aggregation rather than relying on the feature table. What happens when score_batch() runs?
Correct answer: A — score_batch() uses the precomputed transaction_velocity values already present in the batch DataFrame for those rows and only retrieves the remaining features that are missing from the feature table.
- A. When a feature column is already present in the DataFrame passed to
score_batch(), the API treats that as an override and uses the supplied value instead of looking it up, while still fetching any other declared features that are absent. - B. Supplying a feature column that matches a declared feature name does not trigger a validation error; it is the documented way to override a specific feature value rather than a schema conflict.
- C. The API does not discard user-supplied feature values in favor of the feature table; doing so would make it impossible to override a feature for testing or correction, which the scoring API explicitly supports.
- D. There is no struct-merging behavior for overlapping feature columns;
score_batch()uses the existing column values directly rather than combining them with looked-up values into a nested type.
Sources3
4.Time series lookups and keys that are not in the table
A model trained on a time series feature table needs a timestamp, not just an ID. These are time series feature tables (timeseries column in the primary key), and they are joined point in time. For each row, the feature value is the one that was valid at that row's timestamp. score_batch repeats the same point-in-time lookup when it scores, using the metadata packaged with the model. So the scoring DataFrame must include a timestamp column with the same name and DataType as the timestamp_lookup_key used in training. Any lookback window set for training also applies to batch inference. On a Photon-enabled cluster, passing use_spark_native_join=True to FeatureEngineeringClient.score_batch speeds up the lookup. This requires databricks-feature-engineering 0.6.0 or above.
A key that has no matching row in the feature table does not stop the job. The missing feature comes back empty. With fe.score_batch the empty value is always NaN. Model Serving behaves differently: it returns None when none of the request's lookup keys exist and NaN when only some are missing. A model that runs both in batch and behind an endpoint should therefore handle both None and NaN, rather than relying on how batch scoring happens to fill the gap.
The job completes. Those 40 rows get NaN for the customer features, and the model scores them with NaN inputs. Whether those predictions mean anything depends on how the model handles NaN, so handle it in the model, not in the scoring call.
Checkpoint 8 of 9· Check yourself
Training used a FeatureLookup on a time series feature table with timestamp_lookup_key='event_ts', a TimestampType column. Now the team wants to run fe.score_batch on a new batch. What does batch_df need to contain?
score_batch repeats the point-in-time join using the metadata packaged with the model. To do that, the scoring DataFrame needs a timestamp column with the same name and DataType as the timestamp_lookup_key used in training. use_spark_native_join only makes the lookup faster. It does not supply the timestamp.
“must contain a timestamp column with the same name and DataType as the timestamp_lookup_key”Source: docs.databricks.com
5.score_batch compared with pyfunc and Model Serving
score_batch is one of three ways to score a feature store model, and all three can do the lookup. Plain MLflow is the second. Batch inference with mlflow.pyfunc and spark_udf also works on a model logged by the feature store client: mlflow.pyfunc predict fetches the features from the store and joins them with any values you pass in, as long as you supply the primary keys. It has two limits. It needs MLflow 2.11 or above, and it does not support models that use time series feature tables. For those models, use score_batch.
Real-time serving is the third path. When a feature store model is deployed with Model Serving, the endpoint reads every required feature from the online store, not the offline Delta tables. The difference is explained in Offline feature tables vs online store. As in batch, querying a real-time serving endpoint for this kind of model means the request carries only the lookup keys. You override a feature by putting its value in the request payload, and the value must match the data type the model expects.
| Path | Where features come from | Time series feature tables | Override a feature |
|---|---|---|---|
| fe.score_batch | Offline feature tables | Supported (point-in-time lookup) | Add the column to df |
| mlflow.pyfunc predict | Feature Store | Not supported | Values provided at inference are joined |
| Model Serving endpoint | Online store | Latest value used | Include it in the API payload |
Checkpoint 9 of 9· Match them up
Match each way of scoring a model logged with fe.log_model to how it handles feature lookup.
Tap a term, then the definition that fits it.
All three paths can look up features for a model logged with the feature store client. score_batch reads the offline tables and is the only batch path that supports time series feature tables. pyfunc batch inference does not support those models, and Model Serving reads from the online store.
“Models that use time series feature tables are not supported. To do batch inference with time series feature tables, use score_batch.”Source: docs.databricks.com
Sources
(6)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“In batch inference, feature values are retrieved from the offline store and joined with new data prior to scoring.”
↩︎ Why a feature store model needs only keys to score“The caller only needs to provide the primary key of the features used in the model”
↩︎ Key concept“To package a model with feature metadata, use FeatureEngineeringClient.log_model (for Feature Engineering in Unity Catalog) or FeatureStoreClient.log_model (for Workspace Feature Store).”
↩︎ Exam trap 1“To package a model with feature metadata, use FeatureEngineeringClient.log_model (for Feature Engineering in Unity Catalog) or FeatureStoreClient.log_model (for Workspace Feature Store).”
↩︎ Checkpoint - 2.
“To work with feature tables in Unity Catalog, use FeatureEngineeringClient. To use Workspace Feature Store, you must use FeatureStoreClient.”
↩︎ Why a feature store model needs only keys to score - 3.https://docs.databricks.com/aws/en/machine-learning/feature-store/train-models-with-feature-storeOfficial docs
“If the model at model_uri is packaged with the features, the FeatureStoreClient.score_batch()”
↩︎ Why a feature store model needs only keys to score“The DataFrame returned by score_batch() augments batch_df with”
↩︎ Calling score_batch and reading its output“To use custom feature values for scoring, include them in the DataFrame passed to FeatureEngineeringClient.score_batch”
↩︎ Overriding features and adding columns from outside the store“At inference, the DataFrame used in FeatureStoreClient.score_batch must include the browser column.”
↩︎ Overriding features and adding columns from outside the store“For offline applications using fe.score_batch, the returned value for a missing feature is NaN.”
↩︎ Time series lookups and keys that are not in the table“If none of the provided lookup keys exist, the value is None.”
↩︎ Time series lookups and keys that are not in the table“mlflow.pyfunc.predict retrieves feature values from Feature Store and also joins any values provided at inference time.”
↩︎ score_batch compared with pyfunc and Model Serving“Batch inference with MLflow requires MLflow version 2.11 and above.”
↩︎ score_batch compared with pyfunc and Model Serving“the API looks up only the num_lifetime_purchases feature from Feature Store and uses the provided custom account_creation_date column values”
↩︎ Exam trap 2“At inference, the DataFrame used in FeatureStoreClient.score_batch must include the browser column.”
↩︎ Exam trap 3“Models that use time series feature tables are not supported. To do batch inference with time series feature tables, use score_batch.”
↩︎ Exam trap 4“the API looks up only the num_lifetime_purchases feature from Feature Store and uses the provided custom account_creation_date column values for model scoring”
↩︎ Checkpoint“Models that use time series feature tables are not supported. To do batch inference with time series feature tables, use score_batch.”
↩︎ Checkpoint - 4.https://docs.databricks.com/aws/en/machine-learning/feature-store/train-with-declarative-featuresOfficial docs
“score_batch uses the feature metadata stored with the model to automatically compute point-in-time correct features for inference, ensuring consistency with training.”
↩︎ Calling score_batch and reading its output - 5.
“must contain a timestamp column with the same name and DataType as the timestamp_lookup_key of the FeatureLookup”
↩︎ Time series lookups and keys that are not in the table“For faster lookup performance when Photon is enabled, pass use_spark_native_join=True to FeatureEngineeringClient.score_batch.”
↩︎ Time series lookups and keys that are not in the table“The lookback window is applied during training and batch inference.”
↩︎ Time series lookups and keys that are not in the table“During online inference, the latest feature value is always used, regardless of the lookback window.”
↩︎ score_batch compared with pyfunc and Model Serving“must contain a timestamp column with the same name and DataType as the timestamp_lookup_key”
↩︎ Checkpoint - 6.https://docs.databricks.com/aws/en/machine-learning/feature-store/automatic-feature-lookupOfficial docs
“All features required by the model (logged with FeatureEngineeringClient.log_model or FeatureStoreClient.log_model) are automatically looked up from online stores for model scoring.”
↩︎ score_batch compared with pyfunc and Model Serving“include the feature values as a part of the API payload”
↩︎ score_batch compared with pyfunc and Model Serving