
Answer-first summary for fast verification
Answer: They can add %sql to the first line of the cell
In Databricks notebooks, using the magic command `%sql` at the beginning of a cell allows the user to switch the cell language to SQL. This enables the data engineer to run SQL queries within that specific cell while keeping all other cells in Python. The other options either don't allow the use of SQL in a Python notebook or require adjustments that affect other cells or the entire notebook.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
In the context of using a Python notebook within Databricks for data engineering tasks, a data engineer needs to execute a specific task using SQL in one of the cells while keeping all other cells in Python without altering them. How can the data engineer achieve this functionality of incorporating SQL within a single cell of their Python notebook?
A
It is not possible to use SQL in a Python notebook
B
They can attach the cell to a SQL endpoint rather than a Databricks cluster
C
They can simply write SQL syntax in the cell
D
They can add %sql to the first line of the cell
E
They can change the default language of the notebook to SQL
No comments yet.