📘 Free CERTIFIED-DATA-ENGINEER-PROFESSIONAL Sample Questions
An upstream system has been configured to pass the date for a given batch of data to the Databricks Jobs API as a
parameter. The notebook to be scheduled will use this parameter to load data with the following code: df =
spark.read.format("parquet").load(f"/mnt/source/(date)")
Which code block should be used to create the date Python variable used in the above code block?
A
date = spark.conf.get("date")
B
.input_dict = input()
date= input_dict["date"]
C
import sys
date = sys.argv[1]
D
date = dbutils.notebooks.getParam("date")
E
dbutils.widgets.text("date", "null")
date = dbutils.widgets.get("date")
Correct Answer:
E. dbutils.widgets.text("date", "null")
date = dbutils.widgets.get("date")
Explanation:
The correct answer is E, which uses Databricks widgets to handle the date parameter passed from the Jobs
API. Let's break down why:
1. Databricks Widgets: Widgets are UI elements that allow users to pass parameters to notebooks at
runtime. This is crucial for scheduled jobs that need dynamic input. dbutils.widgets.text("date", "null")
creates a text widget named "date" with a default value of "null". dbutils.widgets.get("date") retrieves
the value of this widget. When the Databricks Jobs API calls the notebook, it can override the default
value with the batch date.
2. Why other options are incorrect:
3. A. date = spark.conf.get("date"): spark.conf.get() retrieves Spark configuration properties, not
parameters passed directly to a notebook job. Spark configuration settings are typically for Spark
engine behaviors and resources.
4. B. input_dict = input() date= input_dict["date"]: This approach expects user input via the console,
which is unsuitable for automated, scheduled jobs. Jobs API does not provide console input to
scheduled tasks.
5. C. import sys date = sys.argv[1]: This is suitable for command-line scripts but not Databricks
notebooks invoked by the Jobs API. While sys.argv can pass arguments to a Python script, the
Databricks Jobs API is not designed to directly populate sys.argv when executing notebooks. The Jobs
API parameter passing mechanism is integrated with Databricks dbutils.
6. D. date = dbutils.notebooks.getParam("date"): dbutils.notebooks.getParam() is intended for passing
parameters between notebooks when using the %run magic command or dbutils.notebook.run(), not
for receiving parameters from the Jobs API. It is designed for notebook workflows, not external API
calls.
7. Benefits of using widgets:
8. Parameterization: Widgets enable you to parameterize your notebooks, making them reusable for
different data batches or scenarios.
9. Automation: The Jobs API can set widget values when scheduling notebooks, enabling automated
data processing pipelines.
10. User Interface: Widgets are visible and editable in the Databricks notebook UI, which is useful for
debugging and interactive exploration.
In summary, using Databricks widgets is the correct and most efficient approach for retrieving parameters
passed to a notebook by the Databricks Jobs API, allowing for automated, parameterized data processing
workflows.
Authoritative Links:
1. Databricks Widgets: https://docs.databricks.com/notebooks/widgets.html
2. Databricks Jobs API: https://docs.databricks.com/api/workspace/jobs
3. dbutils.notebook.run(): https://docs.databricks.com/notebooks/notebook-workflows.html#run-a-
notebook
The Databricks workspace administrator has configured interactive clusters for each of the data engineering
groups. To control costs, clusters are set to terminate after 30 minutes of inactivity. Each user should be able to
execute workloads against their assigned clusters at any time of the day.
Assuming users have been added to a workspace but not granted any permissions, which of the following
describes the minimal permissions a user would need to start and attach to an already configured cluster.
A
"Can Manage" privileges on the required cluster
B
Workspace Admin privileges, cluster creation allowed, "Can Attach To" privileges on the required cluster
C
Cluster creation allowed, "Can Attach To" privileges on the required cluster
D
"Can Restart" privileges on the required cluster
E
Cluster creation allowed, "Can Restart" privileges on the required cluster
Correct Answer:
D. "Can Restart" privileges on the required cluster
Explanation:
Here's a detailed justification for why option D ("Can Restart" privileges on the required cluster) is the most
appropriate answer, along with supporting concepts and authoritative links:
The core requirement is to allow users to execute workloads against already configured clusters that might
be terminated due to inactivity. The key here is that the clusters already exist. We are not creating new
clusters. Therefore, any option requiring cluster creation privileges can be immediately eliminated (options B,
C, and E).
"Can Manage" privileges (option A) are far too broad. "Can Manage" grants the user full control over the
cluster, including editing its configuration, resizing it, deleting it, and managing permissions. The question
asks for minimal permissions. "Can Manage" goes beyond the scope of simply starting and attaching.
The Databricks documentation defines specific cluster access control levels. A cluster terminated due to
inactivity does not necessarily need to be completely re-created (requiring "Can Manage"). Instead, it can be
restarted.
When a cluster terminates due to inactivity, it enters a terminated state, but the cluster configuration persists.
A user with "Can Restart" privileges can bring the cluster back online using its existing configuration. Once
the cluster is running, they can then attach to it to execute workloads.
"Can Attach To" is inherently required to execute workloads against a running cluster. However, if the cluster
is terminated, "Can Attach To" alone is insufficient; the cluster must first be restarted. Since the cluster is
configured to terminate after inactivity, the ability to restart becomes crucial.
Therefore, the combination of "Can Restart" allows the user to bring the stopped cluster back up, and
implicitly the ability to "Can Attach To" allows the user to execute workloads when the cluster is running. The
minimal permission required is "Can Restart" because, in the scenario described, the user needs to be able to
bring the cluster from a terminated (inactive) state to a running state, then "Can Attach To" access is given
automatically.
Authoritative Links:
Databricks Cluster Access Control: https://docs.databricks.com/security/access-control/cluster-access-
control.html
Databricks Cluster Lifecycle: https://docs.databricks.com/clusters/clusters-manage.html#cluster-states
When scheduling Structured Streaming jobs for production, which configuration automatically recovers from
query failures and keeps costs low?
A
Cluster: New Job Cluster;
Retries: Unlimited;
Maximum Concurrent Runs: Unlimited
B
Cluster: New Job Cluster;
Retries: None;
Maximum Concurrent Runs: 1
C
Cluster: Existing All-Purpose Cluster;
Retries: Unlimited;
Maximum Concurrent Runs: 1
D
Cluster: New Job Cluster;
Retries: Unlimited;
Maximum Concurrent Runs: 1
E
Cluster: Existing All-Purpose Cluster;
Retries: None;
Maximum Concurrent Runs: 1
Correct Answer:
D. Cluster: New Job Cluster;
Retries: Unlimited;
Maximum Concurrent Runs: 1
Explanation:
Here's a detailed justification for why option D (Cluster: New Job Cluster; Retries: Unlimited; Maximum
Concurrent Runs: 1) is the most appropriate choice for scheduling production Structured Streaming jobs on
Databricks, emphasizing fault tolerance and cost efficiency:
The key requirements for production Structured Streaming jobs are reliability (automatic recovery from
failures) and cost optimization. A "New Job Cluster" is purpose-built for a specific task, which ensures
resource isolation. This means that a failure in one streaming job will not impact other jobs. Creating a new
cluster for each job provides a clean environment.
"Retries: Unlimited" provides the desired fault tolerance. If a streaming query fails due to transient issues
(network glitch, temporary resource unavailability), Databricks will automatically restart it. Without retries, a
failure would require manual intervention, leading to data loss or processing delays.
"Maximum Concurrent Runs: 1" enforces sequential execution. While running multiple concurrent jobs on the
same cluster might seem appealing for resource utilization, it introduces complexity regarding resource
contention and potential interference. Limiting to one run at a time simplifies management and minimizes the
risk of failures due to resource exhaustion.
Option A is incorrect due to "Maximum Concurrent Runs: Unlimited." Running unlimited jobs concurrently
could overload the cluster, leading to instability and increased failure rates. Option B is flawed because
"Retries: None" means the job fails permanently upon encountering an error. Option C is not a good choice due
to using an "Existing All-Purpose Cluster." All-Purpose clusters are designed for interactive use and data
exploration and can lead to resource contention with other jobs if used for production jobs. Option E fails for
the same reason as option C and also has "Retries: None," which makes it prone to permanent failures.
In summary, a new job cluster, unlimited retries, and one concurrent run provides the best balance between
fault tolerance and manageable costs for production Structured Streaming jobs on Databricks. The cluster is
spun up only when needed, minimizing idle time costs, and retries ensure resilience.
For further research, consult Databricks documentation on:
Databricks Jobs: https://docs.databricks.com/workflows/jobs/index.html
Structured Streaming: https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html
Cluster Management: https://docs.databricks.com/clusters/index.html
The data engineering team has configured a Databricks SQL query and alert to monitor the values in a Delta Lake
table. The recent_sensor_recordings table contains an identifying sensor_id alongside the timestamp and
temperature for the most recent 5 minutes of recordings.
The below query is used to create the alert:
SELECT MEAN (temperature), MAX (temperature) , MIN (temperature)
FROM recent_sensor_recordings
GROUP BY sensor _ id
The query is set to refresh each minute and always completes in less than 10 seconds. The alert is set to trigger
when mean (temperature) > 120. Notifications are triggered to be sent at most every 1 minute.
If this alert raises notifications for 3 consecutive minutes and then stops, which statement must be true?
A
The total average temperature across all sensors exceeded 120 on three consecutive executions of the query
B
The recent_sensor_recordings table was unresponsive for three consecutive runs of the query
C
The source query failed to update properly for three consecutive minutes and then restarted
D
The maximum temperature recording for at least one sensor exceeded 120 on three consecutive executions
of the query
E
The average temperature recordings for at least one sensor exceeded 120 on three consecutive executions of the query
Correct Answer:
E. The average temperature recordings for at least one sensor exceeded 120 on three consecutive executions of the query
Explanation:
To understand why E is the correct answer, we must break down how an alert with an aggregation function
like mean() works in most monitoring systems (such as Azure Monitor or similar time-series analysis tools):
The Aggregation Logic: The alert is configured to monitor mean(temperature) > 120. By definition, mean() is an
aggregate calculation performed over the data returned by the query.
120 at that specific moment in time.
The Trigger Condition: When an alert is defined this way, the "trigger" occurs based on the result of the query
execution. If the alert fires, it means the result of that calculation (the average temperature) was greater than
Consecutive Execution: Since the alert triggered for three consecutive minutes, the condition
mean(temperature) > 120 must have evaluated to True for three consecutive query executions.
Why E is specific and correct: It correctly identifies that the mean (average) calculation is the governing
factor. The phrase "at least one sensor" accounts for the fact that the alert is evaluating the dataset returned
by the query; if the query is scoped to the relevant environment, the average across that set is what triggers
the threshold.
Why other options are incorrect:
A: This is a trap. It incorrectly implies a "total" average across "all" sensors without clarifying if the query is
scoped to a specific group or if individual sensors are being compared against the threshold.
B & C: These suggest system failures. If the query failed or the table was unresponsive, the alert would
typically go into an "unknown" or "error" state rather than triggering a notification based on a temperature
threshold.
D: This refers to the maximum temperature. The alert is explicitly configured for the mean (average), not the
max. Relying on the max would ignore the alert's specific logic.
A junior developer complains that the code in their notebook isn't producing the correct results in the development
environment. A shared screenshot reveals that while they're using a notebook versioned with Databricks Repos,
they're using a personal branch that contains old logic. The desired branch named dev-2.3.9 is not available from
the branch selection dropdown.
Which approach will allow this developer to review the current logic for this notebook?
A
Use Repos to make a pull request use the Databricks REST API to update the current branch to dev-2.3.9
B
Use Repos to pull changes from the remote Git repository and select the dev-2.3.9 branch.
C
Use Repos to checkout the dev-2.3.9 branch and auto-resolve conflicts with the current branch
D
Merge all changes back to the main branch in the remote Git repository and clone the repo again
E
Use Repos to merge the current branch and the dev-2.3.9 branch, then make a pull request to sync with the
remote repository
Correct Answer:
B. Use Repos to pull changes from the remote Git repository and select the dev-2.3.9 branch.
Explanation:
The correct approach is B. Use Repos to pull changes from the remote Git repository and select the dev-
2.3.9 branch.
Here's a detailed justification:
The problem stems from the developer working with an outdated version of the code in their personal branch
within Databricks Repos. The desired dev-2.3.9 branch, containing the correct logic, is not locally available. To
rectify this, the developer needs to update their local repository with the latest changes from the remote
repository where dev-2.3.9 resides.
Option B directly addresses this by using Repos' functionality to "pull" (fetch and merge) changes from the
remote Git repository. This action downloads the latest commits and branches, including dev-2.3.9, to the
developer's local repository. Once the pull is complete, the developer can then select (checkout) the dev-2.3.9
branch within Databricks Repos. This will switch the notebook to the version present in that branch, allowing
the developer to review and use the correct logic.
Let's analyze why the other options are not suitable:
1. A: Making a pull request is intended for contributing changes, not for simply acquiring them. Also
using the Databricks REST API to update the current branch feels overly complex for a simple git
update.
2. C: Checking out the branch and auto-resolving conflicts could lead to unintended changes if the
current branch has modifications the developer wants to discard or keep separate.
3. D: Merging to the main branch and recloning is a drastic measure and disrupts the established Git
workflow. It's unnecessary to involve main for a localized branch update.
4. E: Merging the current branch with dev-2.3.9 before pulling could introduce unwanted conflicts if the
developer's local branch contains errors.
Therefore, pulling changes from the remote repository and then selecting the correct branch is the most
efficient and safest way for the junior developer to access the current logic.
Here are some links to further research Databricks Repos and Git operations:
Repository
1. Databricks Repos Documentation: https://docs.databricks.com/repos/index.html
2. Git Basics - Getting a Git Repository: https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git
3. Git Branching - Basic Branching and Merging: https://git-scm.com/book/en/v2/Git-Branching-Basic
Branching-and-Merging
The security team is exploring whether or not the Databricks secrets module can be leveraged for connecting to
an external database.
After testing the code with all Python variables being defined with strings, they upload the password to the
secrets module and configure the correct permissions for the currently active user. They then modify their code to
the following (leaving all other variables unchanged).
A
The connection to the external table will fail; the string "REDACTED" will be printed.
B
An interactive input box will appear in the notebook; if the right password is provided, the connection will
succeed and the encoded password will be saved to DBFS.
C
An interactive input box will appear in the notebook; if the right password is provided, the connection will
succeed and the password will be printed in plain text.
D
The connection to the external table will succeed; the string value of password will be printed in plain text.
E
The connection to the external table will succeed; the string "REDACTED" will be printed.
Correct Answer:
E. The connection to the external table will succeed; the string "REDACTED" will be printed.
Explanation:
The connection to the external table will succeed; the string "REDACTED" will be printed.
https://learn.microsoft.com/en-us/azure/databricks/security/secrets/redaction
The data science team has created and logged a production model using MLflow. The following code correctly imports
and applies the production model to output the predictions as a new DataFrame named preds with the schema
"customer_id LONG, predictions DOUBLE, date DATE".
A
preds.write.mode("append").saveAsTable("churn_preds")
B
preds.write.format("delta").save("/preds/churn_preds")(preds.writeStream.outputMode ("overwrite").option("checkpointPath", "/_checkpoints/churn_preds").start("/preds/churn_preds") )
C
(preds.write
.format("delta")
.mode ("overwrite")
.saveAsTable ("churn_preds")
D
(preds.writeStream
.outputMode ("append")
.option("checkpointPath", "/_checkpoints/churn_preds")
.cable("churn_preds") )
Correct Answer:
A. preds.write.mode("append").saveAsTable("churn_preds")
Explanation:
You need:- Batch operation since it is at most once a day- Append, since you need to keep track of past
predictionsA is the correct answer. You don't need to specify "format" when you use saveAsTable.
An upstream source writes Parquet data as hourly batches to directories named with the current date. A nightly
batch job runs the following code to ingest all data from the previous day as indicated by the date variable:
A
Each write to the orders table will only contain unique records, and only those records without duplicates in
the target table will be written.
B
Each write to the orders table will only contain unique records, but newly written records may have duplicates
already present in the target table.
C
Each write to the orders table will only contain unique records; if existing records with the same key are
present in the target table, these records will be overwritten.
D
Each write to the orders table will only contain unique records; if existing records with the same key are
present in the target table, the operation will fail.
E
Each write to the orders table will run deduplication over the union of new and existing records, ensuring no
duplicate records are present.
Correct Answer:
B. Each write to the orders table will only contain unique records, but newly written records may have duplicates
already present in the target table.
Explanation:
Each write to the orders table will only contain unique records, but newly written records may have duplicates
already present in the target table.
A junior member of the data engineering team is exploring the language interoperability of Databricks notebooks.
The intended outcome of the below code is to register a view of all sales that occurred in countries on the
continent of Africa that appear in the geo_lookup table.
Before executing the code, running SHOW TABLES on the current database indicates the database contains only
two tables: geo_lookup and sales.
A
Both commands will succeed. Executing show tables will show that countries_af and sales_af have been
registered as views.
B
Cmd 1 will succeed. Cmd 2 will search all accessible databases for a table or view named countries_af: if this
entity exists, Cmd 2 will succeed.
C
Cmd 1 will succeed and Cmd 2 will fail. countries_af will be a Python variable representing a PySpark
DataFrame.
D
Both commands will fail. No new variables, tables, or views will be created.
E
Cmd 1 will succeed and Cmd 2 will fail. countries_af will be a Python variable containing a list of strings.
Correct Answer:
E. Cmd 1 will succeed and Cmd 2 will fail. countries_af will be a Python variable containing a list of strings.
Explanation:
Cmd 1 will succeed and Cmd 2 will fail. countries_af will be a Python variable containing a list of strings.
Cmd 1 is a PySpark command that collects the list of countries from the 'geo_lookup' table where the
continent is Africa ('AF'). This command will execute successfully, resulting in countries_af being a list of
country names (strings) in Python's local memory.
Cmd 2 is an SQL command intended to create a view named 'sales_af' from the 'sales' table, filtered by the
cities in the countries_af list. However, this will fail because the countries_af variable exists in the Python
environment and is not recognized in the SQL context. SQL does not have access to Python variables directly;
they are two separate execution contexts within a Databricks notebook. There is no table or view named
countries_af that SQL can reference; it is merely a Python list variable.
The other options are incorrect because they either assume cross-contextual operation between Python and
SQL within a Databricks notebook (which is not possible in the way described in the commands), or they do not
correctly interpret the outcome of running the commands.
A Delta table of weather records is partitioned by date and has the below schema: date DATE, device_id INT, temp
FLOAT, latitude FLOAT, longitude FLOAT
To find all the records from within the Arctic Circle, you execute a query with the below filter: latitude > 66.3
Which statement describes how the Delta engine identifies which files to load?
A
All records are cached to an operational database and then the filter is applied
B
The Parquet file footers are scanned for min and max statistics for the latitude column
C
All records are cached to attached storage and then the filter is applied
D
The Delta log is scanned for min and max statistics for the latitude column
E
The Hive metastore is scanned for min and max statistics for the latitude column
Correct Answer:
D. The Delta log is scanned for min and max statistics for the latitude column
Explanation:
The correct answer is D: The Delta log is scanned for min and max statistics for the latitude column.
Delta Lake enhances data lake reliability and performance by introducing a transaction log that meticulously
records every change made to the data. This log contains metadata, including min/max statistics for each
column within each data file. This enables Delta Lake to intelligently skip irrelevant files during query
execution, a technique known as data skipping. When you execute a query with the filter latitude > 66.3, the
Delta engine uses the transaction log to evaluate the min/max latitude values stored for each data file. If the
minimum latitude value for a particular file exceeds 66.3, that file is guaranteed to contain relevant records
and is included in the read set. Conversely, if the maximum latitude value for a file is less than or equal to
66.3, the file is skipped entirely, significantly reducing I/O operations and accelerating query performance.
The Delta log eliminates the need to scan Parquet file footers directly (option B) or rely on external
metastores like Hive for min/max statistics (option E). Options A and C are incorrect because they involve
caching all records, which defeats the purpose of efficient data skipping. Delta Lake prioritizes reading only
the data that satisfies the query condition.
For further research, consult these resources:
Delta Lake Documentation on Data Skipping: https://docs.databricks.com/delta/data-skipping.html
Delta Lake Under the Hood: https://databricks.com/blog/2019/08/22/diving-into-delta-lake-unpacking-the-
transaction-log.html
Questions: 1-10 out of 412
Continue Full Practice..
GET ALL 412 QUESTIONS