QuestionQ155

VerifiedDeveloping Code for Data Processing using Python and SQL

An upstream system is configured to pass the date for a particular data batch to the Databricks Jobs API as a parameter. The scheduled notebook will use that parameter to load data with the following code:

df = spark.read.format("parquet").load(f"/mnt/source/(date)")  

Which code block should create the date Python variable used in the code above?

Explanation

Databricks notebook tasks access named Jobs parameters through dbutils.widgets. dbutils.widgets.text("date", "null") defines a default widget value, and dbutils.widgets.get("date") retrieves the value passed for the date parameter into the Python variable. Jobs parameter values override the default when the notebook runs as a task.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!