Which Languages Support PREDICT Function in Fabric Notebook

DP-600 By islever Editorial Last updated

Short answer

CD Use Spark SQL and PySpark to perform model scoring with the PREDICT function in a Fabric notebook.

Question

You have a Fabric tenant that contains a machine learning model registered in a Fabric workspace.
You need to use the model to generate predictions by using the PREDICT function in a Fabric notebook.
Which two languages can you use to perform model scoring? Each correct answer presents a complete solution.
NOTE: Each correct answer is worth one point.
  1. T-SQL
  2. DAX
  3. Spark SQL Correct Answer
  4. PySpark Correct Answer

Key Takeaways

The PREDICT function in a Fabric notebook is strictly supported by Spark SQL and PySpark, trapping users who mistakenly assume T-SQL or DAX can be used for Spark-based ML scoring.

Microsoft Fabric notebooks support the PREDICT function for machine learning model scoring using specific Spark-based languages. This page establishes that Spark SQL and PySpark are the correct options for generating predictions.

Common mistake: Choosing T-SQL because it is a prominent query language in Fabric, but it cannot be used in Spark notebooks for the PREDICT function.

Expert Analysis

Why the Answer Is Correct

The PREDICT function in a Microsoft Fabric notebook allows users to score registered machine learning models and generate predictions. According to official documentation, model scoring with PREDICT in a notebook is supported via the Spark SQL API and the PySpark user-defined function (UDF). These Spark-based languages are natively integrated with the underlying Spark compute of the notebook, enabling seamless batch scoring operations.

Why the Other Options Are Wrong

T-SQL is used in Fabric data warehouses and Lakehouse SQL analytics endpoints, not in Spark notebooks for ML model scoring. DAX is an analytical query language used exclusively for Power BI semantic models and has no capability to invoke machine learning models or the PREDICT function in a notebook environment.

Community Comment Notes

Community members strongly agree that notebooks only accept Spark-based languages for this task. As gtc108 pointed out by referencing the official documentation, you can invoke the PREDICT function using the "Spark SQL API PySpark user-defined function". Others, like mtroyano, noted that a "Notebook only accepts the languages: PySpark, Spark, Spark SQL and SparkR", effectively ruling out T-SQL and DAX.

Official Reference

https://learn.microsoft.com/en-us/fabric/data-science/tutorial-data-science-batch-scoring

This link opens the official vendor documentation in a new tab.

Exam Strategy

When asked about notebook languages in Fabric, remember that notebooks run on Spark compute. Therefore, only Spark-based languages like PySpark and Spark SQL are valid for ML scoring, whereas T-SQL and DAX are reserved for warehouses and semantic models.

Discussion 18 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 18

  1. dev2dev 👍 6
    that indicates to use spark sql language.
  2. DarioReymago 👍 4
    yes but you can use "%%sql" in a notebook
  3. gtc108 👍 3
    https://learn.microsoft.com/en-us/fabric/data-science/tutorial-data-science-batch-scoring ou'll load the test dataset into a spark DataFrame and create an MLFlowTransformer object to generate batch predictions. You can then invoke the PREDICT function using one of following three ways: Transformer API from SynapseML Spark SQL API PySpark user-defined function (UDF)
  4. olavrab8 👍 3
    Answer CD Correct T-SQL Cannot be used, nor DAX
  5. wojciech_wie 👍 2
    CD - https://learn.microsoft.com/en-us/azure/synapse-analytics/machine-learning/tutorial-score-model-predict-spark-pool
Show 13 more comments
  1. NadeemSalam 👍 2
    It can be done using python which is only supported in sparksql and pyspark
  2. Vulkany 👍 2
    Notebook only accepts the languages: PySpark, Spark, Spark SQL and SparkR
  3. Momoanwar 👍 2
    C & d in notebook
  4. stilferx 👍 1
    IMHO, the answer is C & D. Link is here: https://learn.microsoft.com/en-us/azure/synapse-analytics/machine-learning/tutorial-score-model-predict-spark-pool Here, """You can call PREDICT three ways, using Spark SQL API, using User define function (UDF), and using Transformer API. """. That means, UDF = PySpark in our case.
  5. semauni 👍 1
    The question asks to do this from a notebook. Spark SQL can be accessed from the notebook using the %%sql-command, while T-SQL cannot. Spark SQL, however, can also be used: https://learn.microsoft.com/en-us/azure/synapse-analytics/machine-learning/tutorial-score-model-predict-spark-pool
  6. DarioReymago 👍 1
    We can use Predict function with T-SQL: https://learn.microsoft.com/en-us/sql/t-sql/queries/predict-transact-sql?view=sql-server-ver16 But I cannot found the Predict function in Spark SQL. Is different to run a predict process in PySpark
  7. rmeng 👍 1
    https://learn.microsoft.com/en-us/azure/synapse-analytics/machine-learning/tutorial-score-model-predict-spark-pool
  8. BrandonPerks 👍 1
    The mention of Fabric Notebook, gives the hint to using Spark. Thus I went with CD
  9. mahesh chowtipalli 👍 1
    Because Notebook only accepts the languages: PySpark, Spark, Spark SQL and SparkR
  10. testtaker45 👍 1
    Thank you for that. I had the same question DarioReymago had.
  11. David_Webb 👍 1
    Using Fabric notebook, thus must be C and D.
  12. NRezgui 👍 1
    PySpark, Spark
  13. jass007_k 👍 1
    Its C and D

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All DP-600 Questions

Access 115 questions with complete answers and detailed explanations.

View Full DP-600 Practice Test →

← Back to DP-600 Study Guide