
Answer-first summary for fast verification
Answer: ```python dbutils.widgets.text("date", "null") date = dbutils.widgets.get("date") ```
### Explanation When a Databricks Job is triggered through the Jobs API using `base_parameters`, Databricks automatically injects these key-value pairs into the notebook session as **Widgets**. * **Correct (D):** The standard practice is to use `dbutils.widgets.text("key", "default")` to ensure the widget exists (especially helpful for interactive development) and then use `dbutils.widgets.get("key")` to retrieve the value passed by the API. ### Why the other options are incorrect: * **Option A:** `spark.conf` is used for Spark configuration properties, not for job parameters passed via the Jobs API. * **Option B:** `sys.argv` is used for passing arguments to standalone Python scripts, but it is not populated with job parameters in Databricks notebooks. * **Option C:** `dbutils.notebook.run()` parameters are distinct from the Job API's `base_parameters`. There is no `dbutils.notebooks.getParam` method for job parameters. * **Option E:** The `input()` function is designed for interactive CLI input, which is not supported during automated Job execution.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
An upstream system triggers a Databricks Job via the Jobs API and passes a date parameter using the base_parameters configuration (e.g., {"date": "2025-07-26"}). Which Python code snippet must be used within the notebook to retrieve this value and assign it to a variable?
A
date = spark.conf.get("date")
date = spark.conf.get("date")
B
import sys
date = sys.argv[1]
import sys
date = sys.argv[1]
C
date = dbutils.notebooks.getParam("date")
date = dbutils.notebooks.getParam("date")
D
dbutils.widgets.text("date", "null")
date = dbutils.widgets.get("date")
dbutils.widgets.text("date", "null")
date = dbutils.widgets.get("date")
E
input_dict = input()
date = input_dict["date"]
input_dict = input()
date = input_dict["date"]
No comments yet.