QuestionQ118

Executing queries using Databricks SQL and Databricks SQL Warehouses

A data analyst is creating a parameterized SQL query in Databricks to filter sales data by region and year. The analyst wants to test the query using different parameter values before adding it to a dashboard.

Which approach should the analyst use to enable dynamic testing of the parameters in the Databricks SQL editor?

  • A Hard-code the region and year values directly into the SQL query and rerun it for each test.
  • B Use parameter markers (e.g., :region, :year) in the SQL query and enter their values in the input boxes before running the query.
  • C Replace the column names (e.g., region, year) with question marks (“?”) and expect Databricks to prompt for values at runtime.
  • D Add the parameters as variables in a Python notebook cell and reference them in the SQL query.
Explanation

Databricks SQL supports named parameter markers such as :region and :year. In the SQL editor, these markers create parameter widgets where values can be entered before execution, allowing the same query to be tested repeatedly with different inputs.

Learn more

Community Discussion

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