
Explanation:
Databricks supports several widget types for parameter input, including text, dropdown, combobox, and multiselect. The correct method to create a text widget is dbutils.widgets.text, where the first argument is the widget name, the second is the default value, and the third is the label. The widget's current value can be retrieved using dbutils.widgets.get. Therefore, the correct snippet is:
dbutils.widgets.text("department", "all", "Department") current_department = dbutils.widgets.get("department")
Ultimate access to all questions.
A data engineer needs to process data based on a 'department' parameter provided to a Databricks notebook at runtime, with a default value of 'all'. Which code snippet correctly creates and assigns this parameter to a Python variable for data processing?
A
dbutils.widgets.options("department", "all", "Department") current_department = dbutils.widgets.get("department")
B
dbutils.widgets.variable("department", "Department", "all") current_department = dbutils.widgets.get("department")
C
dbutils.widgets.text("department", "all", "Department") current_department = dbutils.widgets.get("department")
D
dbutils.widgets.parameter("department", "all", "Department") current_department = dbutils.widgets.get("department")
E
dbutils.widgets.text("department", "Department", "all") current_department = dbutils.widgets.get("department")
No comments yet.