DATABRICKS-DATA-ENGINEER-ASSOCIATE practice question 23 of 25
A data analyst has a series of queries in a SQL program. The data analyst wants this program to run every day. They only want the final query in the program to run on Sundays. They ask for help from the data engineering team to complete this task. Which of the following approaches could be used by the data engineering team to complete this task?
Full set: 177 questionsThe most effective and standard approach within the Databricks platform is to leverage its multi-language capabilities. By wrapping the SQL queries in a PySpark environment (e.g., a Databricks notebook), a data engineer can use Python's native date/time libraries and control flow statements (e.g., if-elif-else). This allows them to check the current day of the week and conditionally execute the final SQL query using the spark.sql() function only on Sundays. The entire notebook can then be scheduled as a daily Databricks Job, satisfying the requirement for the other queries to run every day while the final one runs selectively.
A. Submitting a feature request is not a technical solution; the required functionality already exists through standard programming constructs available in Databricks.
C. This approach violates the primary requirement that the initial part of the program must run every day, not just on Sundays.
D. Using table access control (ACLs) to manage execution logic is an improper use of security features and would likely cause job failures rather than conditional skipping.
E. Redesigning the data model does not solve the core problem, which is about conditional, time-based execution logic, not data structure. ---
1. Databricks Documentation
"Use multiple languages in a notebook": This document explains how to mix languages like Python and SQL within a single Databricks notebook. A Python cell can be used to implement the control logic before calling a SQL query.
Reference: Databricks Documentation > Develop and run code on Databricks > Notebooks > Use multiple languages in a notebook.
2. Databricks Documentation
"PySpark APIs
pyspark.sql.SparkSession.sql": The official API documentation shows that the spark.sql() method is the standard way to execute SQL queries from within a PySpark session. This is the mechanism used to run the conditional query from the Python control block.
Reference: Databricks Documentation > Reference > APIs > PySpark API Reference > pyspark.sql module > SparkSession class > sql method.
3. Databricks Documentation
"Introduction to Databricks Workflows": This documentation confirms that notebooks containing such logic can be scheduled to run on a recurring basis (e.g.
daily). The Python logic within the notebook handles the conditional execution of the specific task.
Reference: Databricks Documentation > Orchestrate data pipelines with Databricks Workflows > Introduction to Databricks Workflows.
Keep practicing
Take the free DATABRICKS-DATA-ENGINEER-ASSOCIATE practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DATABRICKS-DATA-ENGINEER-ASSOCIATE practice questions
- Question 1In which of the following scenarios should a data engineer use the MERGE INTO command ins…
- Question 2Which of the following data workloads will utilize a Gold table as its source?
- Question 3A data engineer has developed a data pipeline to ingest data from a JSON source using Aut…
- Question 4Which two components function in the DB platform architecture’s control plane? (Choose tw…
- Question 5Which of the following code blocks will remove the rows where the value in column age is …
- Question 7Which of the following statements regarding the relationship between Silver tables and Br…
