1.1 Using Python and Tools for development
1.A project managed with a Databricks Asset Bundle requires a job to be parameterized with a processing date. This date needs to be provided dynamically when the job is triggered. How should the `databricks.yml` be configured to define this parameter for the job task, allowing it to be overridden at runtime?
- A.Use Jinja templating within the notebook path like `notebook_path: /src/process_{{params.date}}.py`.
- B.In the task definition, include a `parameters` map with a key for the date and a default value, like `parameters: { 'processing_date': '2023-01-01' }`.
- C.Define a top-level `variables` block in the bundle and reference it in the job, which forces a prompt during manual deployment.
- D.Omit the parameter from the YAML file entirely and rely on the job runner to pass it through the 'additional_parameters' field in a REST API call.
Show answer & explanation
Correct answer: B — In the task definition, include a `parameters` map with a key for the date and a default value, like `parameters: { 'processing_date': '2023-01-01' }`.
- A. Incorrect. Jinja templating in Databricks Asset Bundles is used for substituting variables from the `bundle.variables` block into resource definitions at deployment time. It is not the correct mechanism for defining dynamic, runtime parameters that are passed to a job's code during execution.
- B. Correct. This is the standard and intended method for defining job parameters in a Databricks Asset Bundle. The `parameters` map within a task definition (e.g., `notebook_task`) explicitly declares the parameters the job accepts. Providing a default value is a best practice, and this structure is designed to be easily overridden at runtime via the API, CLI, or UI when the job is triggered.
- C. Incorrect. The top-level `bundle.variables` block is for parameterizing the bundle's infrastructure and resource definitions (e.g., different cluster IDs for dev vs. prod), which are resolved at deployment time. This is distinct from job task parameters, which are values passed to the code at runtime.
- D. Incorrect. While it might be technically possible to pass parameters via the API without declaring them in the YAML, this is against best practices. It undermines the Infrastructure as Code (IaC) principle of having a single, version-controlled source of truth for the job's configuration. For clarity, maintainability, and discoverability, all expected job parameters should be explicitly defined in the `databricks.yml` file.