CertSafari
    Databricks Certified Machine Learning Associate· Lessons

    Domain 4 · Lesson 46/48

    Streaming inference with Lakeflow pipelines (formerly DLT)

    Identify how streaming inference is performed with Delta Live Tables

    17 min read
    2% of exam
    9 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Write a Lakeflow pipeline dataset that scores newly arriving rows with an MLflow model using a model URI, spark_udf and withColumn
    • Choose between a streaming table and a materialized view as the target for predictions
    • Predict which rows a changed model or query affects, and when a full refresh is needed
    • Choose triggered or continuous execution for a scoring pipeline, and generate a starter inference notebook from the model registry

    Key concept

    Streaming table as the prediction target — A streaming table reads each new row from an append-only source once, scores it, and appends the result. Rows that were already scored stay as they are, so each pipeline update only processes what arrived since the last checkpoint.

    1.Where predictions live in a Lakeflow pipeline

    Streaming inference on Databricks is done with a declarative pipeline. Each dataset definition applies the model to rows as they arrive and writes the predictions into a table that the pipeline manages. Delta Live Tables is the old name for this product, which is now Lakeflow pipelines (Lakeflow Spark Declarative Pipelines). Existing DLT code keeps working without migration. In Python, import dlt becomes from pyspark import pipelines as dp, and @dlt decorators become @dp.

    A pipeline is a set of source files that declare datasets, plus a configuration that says how the pipeline runs. You don't write the execution order. The pipeline works out the dependencies between datasets, builds a DAG, and computes upstream datasets before downstream ones. For inference, that lets you declare a raw ingestion table, a scoring table that reads from it, and any aggregates that read from the scores. The pipeline then runs them in the right order.

    The decorator decides what kind of dataset receives the predictions. @dp.table creates a streaming table: a Delta table that processes data incrementally and appends new rows on each update. @dp.materialized_view creates a materialized view, which stays correct by recomputing, for example when a joined dimension changes. That difference determines which one you use for scoring.

    Streaming table versus materialized view as the target for model predictions
    PropertyStreaming table (@dp.table)Materialized view (@dp.materialized_view)
    How input rows are handledEach input row is processed once and appendedRecomputed so the result is always correct
    Joins when a dimension changesDo not recompute (fast but possibly stale)Automatically recomputed
    Best fit for scoringNew events that must be scored as they land, without rescoring old onesResults that must reflect the current state of every input
    Source requirementAppend-only, bounded naturally or with a watermarkAny table the query reads

    For a stream of orders or transactions that need a score when they arrive, use a streaming table. A materialized view can fit when every prediction must reflect the latest joined dimension values. It does not meet the requirement 'score new rows, never rescore old ones', because incremental, once-only processing is what defines a streaming table. Batch and streaming scoring both give high throughput at low cost, with latencies down to minutes. The trade-off against real-time endpoints is covered in Batch vs streaming vs real-time inference.

    Checkpoint 1 of 8· Check yourself

    A team scores card transactions with an MLflow model in a Lakeflow pipeline. The source table is append-only. Each new transaction must be scored when it arrives, and transactions that were already scored must not be rescored on later updates. Which dataset definition should hold the predictions?

    Sources1234

    2.The three-step scoring pattern inside a dataset definition

    Pipelines treat an MLflow model as a transformation: it takes a Spark DataFrame and returns a Spark DataFrame. A pipeline dataset is also defined as a function that returns a DataFrame, so a scoring script needs only a few changes to become a pipeline. The spark_udf mechanics are taught in Batch inference with mlflow.pyfunc and spark_udf. Inside a pipeline they take three steps: build a model URI, turn it into a Spark UDF with mlflow.pyfunc.spark_udf, then call that UDF in withColumn inside the dataset function.

    Basic syntax for applying an MLflow model in a pipeline: model URI, spark_udf, then withColumn in the dataset functionpython
    %pip install mlflow==2.20.2
    
    from pyspark import pipelines as dp
    import mlflow
    
    run_id= "<mlflow-run-id>"
    model_name = "<the-model-name-in-run>"
    model_uri = f"runs:/{run_id}/{model_name}"
    loaded_model_udf = mlflow.pyfunc.spark_udf(spark, model_uri=model_uri)
    
    @dp.materialized_view
    def model_predictions():
      return (
        spark.read.table(<input-data>)
        .withColumn("prediction", loaded_model_udf(<model-features>))
      )

    This sample is a batch materialized view. Two changes make it streaming. First, switch the decorator to @dp.table. Second, read the source with spark.readStream.table(...) instead of spark.read.table(...). The UDF stays where it was. The pipeline join example below shows the streaming read form in a @dp.table function.

    A streaming table: @dp.table with a readStream sourcepython
    @dp.table
    def customer_sales():
      return spark.readStream.table("sales").join(spark.read.table("customers"), ["customer_id"], "left")

    spark_udf returns a column function, not a model object. You call it on the feature columns, packed into a single column with struct(...) from pyspark.sql.functions; in the snippet below, features is a Python list of column names. The result goes in as a new column with .withColumn("prediction", ...). It has no .transform(df) method like an MLlib Transformer. Calling .toPandas() on a streaming DataFrame and returning a pandas object also breaks the contract, because a dataset function must return a Spark DataFrame. Passing the streaming DataFrame to pyfunc.load_model(...).predict() fails for the same reason: the model is applied through the UDF, row by row, across the cluster.

    Packing the feature columns with struct(...) when calling the UDF inside withColumnpython
    def loan_risk_predictions():
      return (
        spark.read.table("loan_risk_input_data")
        .withColumn('predictions', loaded_model_udf(struct(features)))
      )

    The URI decides which model version the pipeline scores with. The sample uses a runs:/ URI, which pins one training run. For a registered model, point the URI at an alias, for example models:/catalog.schema.model@Champion. When someone moves the alias to a new version, the pipeline scores with that version without any code change. Alias management is taught in Model aliases (Champion / Challenger).

    Checkpoint 2 of 8· Check yourself

    Inside a @dp.table function that reads orders with spark.readStream.table("orders"), you have loaded_model_udf = mlflow.pyfunc.spark_udf(spark, model_uri=model_uri). How should the function apply the model to produce predictions?

    Checkpoint 3 of 8· Exam question

    A machine learning engineer is building a Lakeflow Spark Declarative Pipeline (the rebranded Delta Live Tables) that must score newly arriving rows in the bronze_orders table with a registered MLflow model as soon as they land, without recomputing predictions for orders that were already scored on a previous run. Which approach correctly implements this streaming inference pattern?

    Checkpoint 4 of 8· Exam question

    A model is registered in Unity Catalog and referenced by the alias champion. Inside a Lakeflow pipeline dataset function that reads a streaming source, which snippet correctly loads and applies that model to produce a prediction column?

    Sources56

    3.What gets scored, and what never gets rescored

    A streaming table scores each input row once. Its default flow is an append flow that adds new rows on each update, and only new input data is read. Progress is tracked with checkpoint management. When a pipeline restarts mid-run, it resumes from the checkpoint instead of rescanning the source, so transactions that were already processed are not scored a second time.

    Once-only processing also means changes are not applied to old rows. The docs illustrate this with a query edit: change SELECT LOWER(name) to SELECT UPPER(name), and existing rows stay lowercase while new rows are uppercase. A new model version behaves the same way. After a promotion, one streaming table can hold rows scored by the old version and rows scored by the new one. To rescore everything with the current model, run a full refresh, which re-reads all previous data from the source and updates every row.

    Watermarks are about state, not about whether the model can run. Streaming tables expect streams that are bounded, either naturally (a finite set of files) or by a watermark. A watermark says how long to wait for late events before treating a time window as complete. A plain row-by-row scoring query needs no watermark for the UDF to run, and out-of-order rows are not dropped from scoring. Watermarks matter when the query keeps unbounded state, such as windowed aggregations. Without one, that kind of stream can fail the pipeline from memory pressure.

    Joins are the other place where streaming scores can go stale. If the scoring query joins the stream to a dimension table, such as customer attributes used as features, the join is not recomputed when the dimension changes. That is fine when speed matters more than perfect accuracy. If every prediction must reflect current dimension values, a materialized view is the correct target.

    Checkpoint 5 of 8· Match them up

    Match each situation in a streaming scoring pipeline to what handles it.

    Tap a term, then the definition that fits it.

    Checkpoint 6 of 8· Exam question

    A fraud-detection team streams scored transactions through a Lakeflow pipeline and is concerned about duplicate predictions being written if the pipeline restarts mid-run. Assuming transactions_bronze is an append-only source, what should the team expect from the streaming table that applies the model?

    Sources375

    4.Triggered or continuous: when the predictions refresh

    How often predictions refresh depends on the pipeline mode, not the table type. Both streaming tables and materialized views can run in either mode. In triggered mode, the pipeline processes the data available when the update started and then stops. In continuous mode, it keeps processing new data as it arrives.

    Triggered versus continuous pipeline mode for a scoring pipeline
    QuestionTriggeredContinuous
    When does the update stop?Automatically when completeRuns until manually stopped
    What data is processed?Data available when the update startsAll data as it arrives at configured sources
    Freshness it suitsEvery 10 minutes, hourly, or dailyBetween every 10 seconds and a few minutes
    Cost profileCluster runs only long enough to updateAlways-running cluster, more expensive, lower latency

    Pick the mode based on how stale a prediction can be. A churn score that feeds a daily retention email can run as an hourly triggered update and pay for compute only during that run. A fraud flag that has to appear within a minute of the card swipe needs continuous execution. In continuous mode, the pipeline watches the Delta tables it depends on and updates only when their contents change.

    Checkpoint 7 of 8· Check yourself

    Fraud flags from a streaming scoring table currently come from an hourly scheduled job that runs the pipeline in triggered mode. The business now needs each flag within a minute of the card swipe. What change meets this requirement the way Databricks recommends?

    Sources8

    5.Generating the inference notebook from the model registry

    You can generate a starting scoring notebook from the model registry instead of writing it by hand. Use the model's inference dialog in the workspace model registry and choose the Streaming (Lakeflow pipelines) tab. Then:

    1. Select the model version to score with.
    2. Browse to the input table. In Unity Catalog workspaces you pick it as catalog.schema.table.
    3. Name the output Lakeflow dataset that will store the predictions.

    The generated notebook uses the input table as its source and applies the model through the MLflow PySpark inference UDF, the same pattern as the previous section. By default it writes to a live table, the older DLT name for a dataset that is not streaming: like a materialized view, it is recomputed from its input on every update rather than appended to. The streaming alternative, which the docs call a streaming live table, is what this lesson calls a streaming table. Common edits are turning the output into a streaming table, adding schema information, or adding data quality constraints. You can create a new pipeline from the notebook or add it to an existing pipeline as another source library.

    The version picker in this legacy dialog can follow the registry. If you choose the current Production or Staging entry, the notebook uses whichever version holds that stage when it runs, so you don't edit the notebook after each new version. In Unity Catalog, an alias-based URI gives the same 'follow the promoted model' behaviour.

    Checkpoint 8 of 8· Check yourself

    You generate a scoring notebook from the workspace model registry's Streaming (Lakeflow pipelines) tab and choose the current Production entry in the Model version picker. You then edit the output into a streaming table and run the pipeline. A month later, a newer model version is moved to Production. What happens on the next pipeline updates?

    Sources95

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “The product formerly known as Delta Live Tables (DLT) has been updated to Lakeflow pipelines.”
      ↩︎ Where predictions live in a Lakeflow pipeline
      “The @table decorator is now used to create streaming tables, and the new @materialized_view decorator is used to create materialized views.”
      ↩︎ Where predictions live in a Lakeflow pipeline
    2. 2.
      “Pipelines automatically infer dependencies between datasets and arrange them in a directed acyclic graph (DAG).”
      ↩︎ Where predictions live in a Lakeflow pipeline
    3. 3.
      “A streaming table is a Delta table with additional support for streaming or incremental data processing.”
      ↩︎ Where predictions live in a Lakeflow pipeline
      “Materialized views are always correct because they automatically recompute joins when dimensions change.”
      ↩︎ Where predictions live in a Lakeflow pipeline
      “A row that has already been appended to a streaming table will not be re-queried with later updates to the pipeline.”
      ↩︎ What gets scored, and what never gets rescored
      “Streaming tables use checkpoint management, which makes them well-suited for low-latency streaming.”
      ↩︎ What gets scored, and what never gets rescored
      “You can trigger a full refresh to requery all previous data from the source table to update all rows in the streaming table.”
      ↩︎ What gets scored, and what never gets rescored
      “An unbounded stream that does not have a watermark can cause a pipeline to fail due to memory pressure.”
      ↩︎ What gets scored, and what never gets rescored
      “Joins in streaming tables do not recompute when dimensions change.”
      ↩︎ What gets scored, and what never gets rescored
      “Streaming tables are designed for append-only data sources and process inputs only once.”
      ↩︎ Key concept
      “Streaming tables are designed for append-only data sources and process inputs only once.”
      ↩︎ Exam trap 1
      “You can trigger a full refresh to requery all previous data from the source table to update all rows in the streaming table.”
      ↩︎ Exam trap 3
      “An unbounded stream that does not have a watermark can cause a pipeline to fail due to memory pressure.”
      ↩︎ Exam trap 4
      “Streaming tables are designed for append-only data sources and process inputs only once.”
      ↩︎ Checkpoint
      “To reprocess existing rows that were processed prior to the change, a full refresh is required.”
      ↩︎ Checkpoint
    4. 4.
      “Batch and streaming scoring supports high-throughput, low-cost scoring at latencies as low as minutes.”
      ↩︎ Where predictions live in a Lakeflow pipeline
    5. 5.
      “MLflow models are treated as transformations in Databricks, meaning they act upon a Spark DataFrame input and return results as a Spark DataFrame.”
      ↩︎ The three-step scoring pattern inside a dataset definition
      “Use the URI to define a Spark UDF to load the MLflow model.”
      ↩︎ The three-step scoring pattern inside a dataset definition
      “Call the UDF in your table definitions to use the MLflow model.”
      ↩︎ The three-step scoring pattern inside a dataset definition
      “The data columns used to make the prediction are passed as an argument to the UDF.”
      ↩︎ The three-step scoring pattern inside a dataset definition
      “To use MLflow models in a Unity Catalog-enabled pipeline, your pipeline must be configured to use the preview channel.”
      ↩︎ The three-step scoring pattern inside a dataset definition
      “Pipelines do not install MLflow by default”
      ↩︎ The three-step scoring pattern inside a dataset definition
      “Only new input data is read with each update.”
      ↩︎ What gets scored, and what never gets rescored
      “By default, pipelines recompute table results based on input data each time they are updated”
      ↩︎ Generating the inference notebook from the model registry
      “MLflow models are treated as transformations in Databricks, meaning they act upon a Spark DataFrame input and return results as a Spark DataFrame.”
      ↩︎ Exam trap 2
    6. 6.
      “You can then update the production model by reassigning the “Champion” alias to a different model version.”
      ↩︎ The three-step scoring pattern inside a dataset definition
    7. 7.
      “the default flow is an append flow that adds new rows with each update”
      ↩︎ What gets scored, and what never gets rescored
    8. 8.
      “Pipeline mode is independent of the type of table being computed.”
      ↩︎ Triggered or continuous: when the predictions refresh
      “If the pipeline uses triggered mode, the system stops after refreshing all tables based on the data available when the update started.”
      ↩︎ Triggered or continuous: when the predictions refresh
      “Continuous pipelines require an always-running cluster, which is more expensive but reduces processing latency.”
      ↩︎ Triggered or continuous: when the predictions refresh
      “Databricks recommends running continuous pipelines with a continuous job rather than setting the value of Pipeline mode to continuous.”
      ↩︎ Triggered or continuous: when the predictions refresh
      “Standalone materialized views and streaming tables always run in triggered mode, regardless of job orchestration.”
      ↩︎ Triggered or continuous: when the predictions refresh
    9. 9.
      “integrates the MLflow PySpark inference UDF to perform model predictions”
      ↩︎ Generating the inference notebook from the model registry
      “define a streaming live table as output, add schema information or data quality constraints”
      ↩︎ Generating the inference notebook from the model registry
      “You can then either create a new pipeline with this notebook or add it to an existing pipeline as an additional notebook library.”
      ↩︎ Generating the inference notebook from the model registry
      “When you select one of these options, the notebook automatically uses the Production or Staging version as of the time it is run.”
      ↩︎ Generating the inference notebook from the model registry
      “creates a data transform that uses the input table as a source and integrates the MLflow PySpark inference UDF to perform model predictions”
      ↩︎ Checkpoint

    Spotted a mistake, or was something unclear? Tell us.