Skip to content

Machine Learning Associate · Domain 1: Databricks Machine Learning · 38% of the exam

Task 1.3: Identify the benefits of creating feature store tables at the account level in Unity Catalog in Databricks vs at the workspace level; Create a feature store table in Unity Catalog; Write data to a feature store table; Train a model with features from a feature store table; Score a model using features from a feature store table; Describe the differences between online and offline feature tables

Feature tables as Delta tables with a primary key in Unity Catalog, FeatureEngineeringClient create_table and write_table, FeatureLookup and create_training_set, log_model and score_batch, and publishing to an online feature store for real-time lookups.

Study it

  • Feature tables in Unity Catalog: create, write, train and score

    Lesson coming

  • Offline feature tables and online feature stores

    Lesson coming

Sample questions

Try each one before opening the answer. Every option is explained, with the Databricks documentation page that proves it.

Question 1 · choose 1

A data science team in workspace A builds daily customer features with full history. The fraud team works in workspace B, which is attached to the same Unity Catalog metastore, and a subsidiary uses its own Databricks account with a different metastore. Both teams train models on historical feature values and must use the same features without the data science team maintaining copies. What should the data science team do?

  1. ACreate the features in the Workspace Feature Store of workspace A and grant workspace B and the subsidiary access to it
  2. BCreate a feature table in Unity Catalog and grant the subsidiary's users privileges on it in workspace A's metastore
  3. CCreate a feature table in Unity Catalog, let workspace B read it directly, and share it with the subsidiary through OpenSharing
  4. DCreate a feature table in Unity Catalog and a simple SELECT view of it for each team to train from
Show the answer and why
  • ACreate the features in the Workspace Feature Store of workspace A and grant workspace B and the subsidiary access to it

    Incorrect

    The Workspace Feature Store is deprecated; cross-workspace access comes with feature tables in Unity Catalog.

  • BCreate a feature table in Unity Catalog and grant the subsidiary's users privileges on it in workspace A's metastore

    Incorrect

    Workspaces that are not assigned to the table's metastore are reached through OpenSharing, not through grants in that metastore.

  • CCreate a feature table in Unity Catalog, let workspace B read it directly, and share it with the subsidiary through OpenSharing

    Correct

    A Unity Catalog feature table is accessible from every workspace assigned to its metastore, and OpenSharing reaches workspaces outside it.

  • DCreate a feature table in Unity Catalog and a simple SELECT view of it for each team to train from

    Incorrect

    A view in workspace A's metastore is still outside the subsidiary's metastore; workspaces on another metastore are reached through OpenSharing.

Feature tables in Unity Catalog bring governance, lineage and cross-workspace sharing and discovery. A feature table is accessible to all workspaces assigned to its metastore; for workspaces that are not assigned to the same metastore, Databricks points to OpenSharing. The Workspace Feature Store is deprecated.

Question 2 · choose 2

A data scientist wants to use the existing Unity Catalog Delta table ml.retail.store_stats, which has no constraints, as a feature table keyed on store_id. Which two conditions must hold before ALTER TABLE ml.retail.store_stats ADD CONSTRAINT store_stats_pk PRIMARY KEY (store_id) succeeds? (Choose TWO.)

  1. AChange data feed is enabled on the table
  2. BThe store_id column has been altered to NOT NULL
  3. CThe table was created with FeatureEngineeringClient.create_table
  4. Dstore_id is declared with the TIMESERIES keyword
  5. EThe statement is run by the owner of the table
Show the answer and why
  • AChange data feed is enabled on the table

    Incorrect

    Change data feed is a prerequisite for some online publish modes, not for declaring a primary key.

  • BThe store_id column has been altered to NOT NULL

    Correct

    Primary key columns are set to NOT NULL first, then the constraint is added.

  • CThe table was created with FeatureEngineeringClient.create_table

    Incorrect

    An existing Delta table can be made a feature table by adding the constraint with ALTER TABLE.

  • Dstore_id is declared with the TIMESERIES keyword

    Incorrect

    TIMESERIES marks a time column of a time series feature table; store_id is a plain key.

  • EThe statement is run by the owner of the table

    Correct

    Only the table owner can declare primary key constraints.

To turn an existing Unity Catalog Delta table into a feature table, set each primary key column to NOT NULL with ALTER TABLE ... ALTER COLUMN ... SET NOT NULL and then add the PRIMARY KEY constraint. Only the table owner can declare primary key constraints; the table then appears in the Features UI.

Question 3 · choose 1

The feature table ml.recommender.customer_features, with primary key customer_id, is refreshed every day and is used by several models. A data scientist writes a new function that computes one new feature, days_since_last_visit, for every customer. How should she add the new feature to the existing table?

  1. ARun write_table with customer_id and the new column; values merge on the key
  2. BChange the primary key to (customer_id, days_since_last_visit) and rewrite the table
  3. CDrop the table and recreate it with create_table, including the new column
  4. DRename an unused feature column to days_since_last_visit and overwrite its values
Show the answer and why
  • ARun write_table with customer_id and the new column; values merge on the key

    Correct

    A DataFrame that contains the primary key and the new feature, written with write_table, updates the schema and merges the values on the key.

  • BChange the primary key to (customer_id, days_since_last_visit) and rewrite the table

    Incorrect

    The primary key is metadata that should not be changed; doing so breaks the downstream pipelines that train and serve with the table.

  • CDrop the table and recreate it with create_table, including the new column

    Incorrect

    Deleting a feature table can break its downstream consumers such as models, endpoints and jobs.

  • DRename an unused feature column to days_since_last_visit and overwrite its values

    Incorrect

    The name or data type of an existing feature should not be changed, because that breaks downstream pipelines.

You can add features to a feature table in Unity Catalog by running write_table with a DataFrame from a new computation function that includes the primary key; the schema is updated and values are merged on the key. The primary key, partition key and existing feature names or types should not be changed, and dropping a feature table can break its consumers.

Question 4 · choose 1

The feature table ml.fraud.card_daily has the primary key (card_id, as_of_date), where as_of_date is a DATE column that was not given a time series designation. A training DataFrame holds card_id, txn_ts and a label, and each transaction must get the most recent feature values from on or before its own timestamp. create_training_set returns an error about the DATE key. What fixes it?

  1. APass lookup_key=["card_id", "txn_ts"] in the FeatureLookup so that both key columns are matched
  2. BChange as_of_date to STRING so that both key columns are matched exactly
  3. CExclude as_of_date with exclude_columns in create_training_set
  4. DDeclare as_of_date as a time series column of the table and pass timestamp_lookup_key="txn_ts" in the FeatureLookup
Show the answer and why
  • APass lookup_key=["card_id", "txn_ts"] in the FeatureLookup so that both key columns are matched

    Incorrect

    Timestamp columns should not be used as a lookup_key, and a plain key match does not pick earlier rows.

  • BChange as_of_date to STRING so that both key columns are matched exactly

    Incorrect

    A STRING key gives exact-match semantics, so transactions would not get the latest earlier values.

  • CExclude as_of_date with exclude_columns in create_training_set

    Incorrect

    exclude_columns removes columns from the training DataFrame; it does not change how the feature table is joined.

  • DDeclare as_of_date as a time series column of the table and pass timestamp_lookup_key="txn_ts" in the FeatureLookup

    Correct

    A DATE primary key must be a timeseries key, and with timestamp_lookup_key the join becomes a point-in-time (as-of) lookup.

DATE or TIMESTAMP primary key columns must be declared as timeseries keys, or create_training_set, create_feature_spec and publish_table return an error. Declaring the column as a time series column (timeseries_columns, or the TIMESERIES keyword) and passing timestamp_lookup_key makes the join an as-of join that matches the latest row before each timestamp. Changing the type to STRING is the fix only for exact-match keys.

Question 5 · choose 1

A model was logged with FeatureEngineeringClient.log_model. Its training set used the features account_age_days and num_purchases from a feature table keyed on customer_id, plus a browser column from the label DataFrame. For a batch run, batch_df holds customer_id, browser and an account_age_days column that the team recomputed today. What does fe.score_batch(model_uri=model_uri, df=batch_df) do?

  1. AIt looks up only num_purchases, uses the supplied account_age_days and browser, and returns batch_df with the features and a prediction column
  2. BIt looks up both features from the feature table and ignores the supplied account_age_days column
  3. CIt fails, because browser is not a feature table column and cannot be passed at scoring time
  4. DIt returns a DataFrame with only customer_id and a prediction column
Show the answer and why
  • AIt looks up only num_purchases, uses the supplied account_age_days and browser, and returns batch_df with the features and a prediction column

    Correct

    Supplied feature columns replace the lookup for those features, extra training columns come from batch_df, and the output adds feature and prediction columns.

  • BIt looks up both features from the feature table and ignores the supplied account_age_days column

    Incorrect

    A feature column that is present in the scoring DataFrame is used instead of the stored value.

  • CIt fails, because browser is not a feature table column and cannot be passed at scoring time

    Incorrect

    Columns from outside the feature store that the model was trained with must be provided in the scoring DataFrame.

  • DIt returns a DataFrame with only customer_id and a prediction column

    Incorrect

    score_batch augments batch_df with the feature values and a column of predictions.

A model packaged with feature metadata looks up its features from the feature tables at inference, except those whose values are supplied in the DataFrame passed to score_batch. Data from outside the feature store that the model was trained with, such as browser here, must be included at inference. The result is batch_df plus the feature columns and a prediction column.

Question 6 · choose 1

The offline feature table ml.risk.customer_scores has the primary key (customer_id, ts TIMESERIES) and keeps every daily value. It was published to a Databricks Online Feature Store for a serving endpoint. An audit service now queries the online store for a customer's score on a given past date and finds only one row per customer. What explains this, and what serves the audit service?

  1. AThe publish mode was TRIGGERED; republishing with CONTINUOUS mode streams the earlier daily rows to the online store
  2. BTime series tables publish only each entity's latest value; publish one without that designation, keyed by a STRING date
  3. CThe online table holds the full history, so the audit service should run an as-of query on ts against it, as point-in-time joins do
  4. DChange data feed is disabled on the source; enabling it makes the online store keep every version of each row
Show the answer and why
  • AThe publish mode was TRIGGERED; republishing with CONTINUOUS mode streams the earlier daily rows to the online store

    Incorrect

    Publish modes control when changes sync; a time series table is still deduplicated to the latest value per entity.

  • BTime series tables publish only each entity's latest value; publish one without that designation, keyed by a STRING date

    Correct

    Without time series designation all rows are published, and the date as a STRING key gives the exact entity-and-date lookup the audit needs.

  • CThe online table holds the full history, so the audit service should run an as-of query on ts against it, as point-in-time joins do

    Incorrect

    Lookups in the online store are exact-match on the key, not point-in-time or range queries, and the history was deduplicated.

  • DChange data feed is disabled on the source; enabling it makes the online store keep every version of each row

    Incorrect

    Change data feed lets the incremental modes sync changes; it does not make the online store keep historical values.

The offline store keeps the full history for training and batch inference. When a time series feature table is published, rows with the same entity key are deduplicated so that only the latest values reach the online store, which suits model and feature serving. To look up a past value by entity and exact date, publish a table created without time series designation; a DATE or TIMESTAMP column used as a plain key is changed to STRING.

Question 7 · choose 1

A data scientist wants to use FeatureEngineeringClient for feature tables in Unity Catalog. On which compute is the client available without installing anything?

  1. AAny Databricks Runtime 12.2 LTS cluster
  2. BA SQL warehouse
  3. CAny standard (non-ML) Databricks Runtime 15.4 LTS cluster
  4. DDatabricks Runtime 13.3 LTS ML and above
Show the answer and why
  • AAny Databricks Runtime 12.2 LTS cluster

    Incorrect

    Feature Engineering in Unity Catalog needs Databricks Runtime 13.2 or above.

  • BA SQL warehouse

    Incorrect

    The Python client runs in notebooks on Databricks Runtime compute.

  • CAny standard (non-ML) Databricks Runtime 15.4 LTS cluster

    Incorrect

    On a non-ML runtime you must install the client manually.

  • DDatabricks Runtime 13.3 LTS ML and above

    Correct

    FeatureEngineeringClient is pre-installed in Databricks Runtime 13.3 LTS ML and above.

FeatureEngineeringClient comes in the databricks-feature-engineering package on PyPI and is pre-installed in Databricks Runtime 13.3 LTS ML and above. On a non-ML runtime you install it with %pip install databricks-feature-engineering.

Question 8 · choose 1

A model is trained with features from feature tables in Unity Catalog. An auditor later asks which feature tables the model used. What does Databricks provide?

  1. ANothing automatic; the team must document the features by hand in a notebook
  2. BA list kept only inside the training notebook's cell outputs
  3. CAutomatic lineage from the model to its features in Catalog Explorer
  4. DLineage only when the model is served on an endpoint
Show the answer and why
  • ANothing automatic; the team must document the features by hand in a notebook

    Incorrect

    Models trained with feature store features track their lineage to those features automatically.

  • BA list kept only inside the training notebook's cell outputs

    Incorrect

    Lineage is recorded with the model and shown in Catalog Explorer, not only in notebook output.

  • CAutomatic lineage from the model to its features in Catalog Explorer

    Correct

    Tables and functions used to create the model are tracked and displayed in Catalog Explorer.

  • DLineage only when the model is served on an endpoint

    Incorrect

    Lineage is tracked when the model is trained, whether or not it is served.

When you train a model with features from Databricks Feature Store, the model automatically tracks lineage to the features it was trained on, and you can view the tables and functions used in Catalog Explorer.

Question 9 · choose 1

A data scientist computes features from spark.readStream on a transactions table and passes the resulting streaming DataFrame to fe.write_table with mode="merge". What does write_table return?

  1. AA new feature table version number
  2. BNothing, after writing one micro-batch
  3. CAn error, because write_table accepts only batch DataFrames
  4. DA StreamingQuery for the running stream
Show the answer and why
  • AA new feature table version number

    Incorrect

    With a streaming DataFrame, write_table starts a streaming pipeline and returns its query object.

  • BNothing, after writing one micro-batch

    Incorrect

    The write keeps running as a streaming feature computation pipeline.

  • CAn error, because write_table accepts only batch DataFrames

    Incorrect

    write_table accepts a streaming DataFrame to create a streaming feature pipeline.

  • DA StreamingQuery for the running stream

    Correct

    Passing a streaming DataFrame to write_table creates a streaming feature computation pipeline and returns a StreamingQuery.

To keep a feature table up to date continuously, pass a streaming DataFrame to write_table. This creates a streaming feature computation pipeline, and the method returns a StreamingQuery object.

Question 10 · choose 1

A training set needs a feature named height from a customer feature table and a feature also named height from a product feature table. How does the data scientist keep both in the DataFrame returned by load_df?

  1. ARename one column in the feature table with ALTER TABLE
  2. BGive each FeatureLookup its own output_name, such as customer_height and product_height
  3. CList height twice in one FeatureLookup's feature_names
  4. DPass exclude_columns=["height"] to create_training_set
Show the answer and why
  • ARename one column in the feature table with ALTER TABLE

    Incorrect

    Renaming an existing feature breaks downstream pipelines; FeatureLookup can rename its output instead.

  • BGive each FeatureLookup its own output_name, such as customer_height and product_height

    Correct

    output_name is used in place of the feature name in the DataFrame that load_df returns.

  • CList height twice in one FeatureLookup's feature_names

    Incorrect

    One FeatureLookup reads from a single table; the two features come from different tables.

  • DPass exclude_columns=["height"] to create_training_set

    Incorrect

    exclude_columns drops columns from the result, so a height feature would be lost.

When two feature tables have features with the same name, set the optional output_name argument of each FeatureLookup. The DataFrame returned by TrainingSet.load_df then contains the renamed columns, for example customer_height and product_height.

Question 11 · choose 1

A batch DataFrame passed to fe.score_batch contains a customer_id that does not exist in the feature table the model looks up. What value does that customer get for the looked-up features?

  1. AThe feature's default value of 0
  2. BNone for every feature
  3. CNaN
  4. DThe batch fails with a lookup error
Show the answer and why
  • AThe feature's default value of 0

    Incorrect

    score_batch returns NaN for a missing feature unless default values were defined for it.

  • BNone for every feature

    Incorrect

    None can appear in online serving; offline score_batch returns NaN.

  • CNaN

    Correct

    For offline applications using fe.score_batch, the value returned for a missing feature is NaN.

  • DThe batch fails with a lookup error

    Incorrect

    A non-existent lookup key returns a missing value; the model must handle it.

When a lookup key does not exist, the feature value can be None or NaN depending on the environment. With fe.score_batch the returned value is NaN; in Model Serving it can be None or NaN. Models should handle both, or the FeatureLookup can define default values.

Question 12 · choose 1

A data scientist's cluster runs Databricks Runtime 15.4 LTS ML. She wants to create a Databricks Online Feature Store with FeatureEngineeringClient and publish a feature table to it for a serving endpoint. Which compute does the Online Feature Stores page require?

  1. ADatabricks Runtime 16.4 LTS ML or above, or serverless compute
  2. BHer 15.4 LTS ML cluster, after installing databricks-feature-engineering 0.13.0 or above with %pip
  3. CDatabricks Runtime 17.3 LTS ML only
  4. DAny Databricks Runtime ML version, because the online store reads the offline table directly
Show the answer and why
  • ADatabricks Runtime 16.4 LTS ML or above, or serverless compute

    Correct

    Databricks Online Feature Stores require Databricks Runtime 16.4 LTS ML or above, and serverless compute can be used as well.

  • BHer 15.4 LTS ML cluster, after installing databricks-feature-engineering 0.13.0 or above with %pip

    Incorrect

    The package version is only part of the requirement; Online Feature Stores also need Databricks Runtime 16.4 LTS ML or above, or serverless compute.

  • CDatabricks Runtime 17.3 LTS ML only

    Incorrect

    16.4 LTS ML is already enough, and serverless compute can also be used.

  • DAny Databricks Runtime ML version, because the online store reads the offline table directly

    Incorrect

    The requirement is 16.4 LTS ML or above, and publish_table syncs the feature data from the offline table into the online store.

The Online Feature Stores page lists one requirement: Databricks Runtime 16.4 LTS ML or above, or serverless compute, with the databricks-feature-engineering package (0.13.0 or above) installed in the notebook. Creating a store with create_online_store and running publish_table then syncs the feature table's data into the online store. Installing the package on an older runtime does not meet the runtime requirement.

Practice domain 1 →Practice all domains →