databricks parameters

databricks notebook / job parameters


A databricks notebook can accept parameters


One way is using the widgets, which reads the dictionary of 

    environment = dbutils.widgets.get("environment")

When running the notebook interactively instead of from a job, the widgets.get will fail "No input widget named environment is defined"


Another way is using getCurrentBindings. 

    parameters = dbutils.notebook.entry_point.getCurrentBindings()

    environment = parameters['environment']

The returned parameters is a dictionary {'foo': 'bar'}. If no parameter it will be an empty dictionary {}.

This works when the notebook is run from a job with parameter, otherwise running the notebook interactively just returns an empty dictionary.


In a databricks job, a notebook is referenced through task. A job can have multiple tasks.

Parameters specified for the job are inherited by all tasks. If same parameter, the task parameter will be overwritten by job parameter.