DP-300 practice question 2 of 35

You are creating a new notebook in Azure Databricks that will support R as the primary language but will also support Scala and SQL. Which switch should you use to switch between languages?

Full set: 407 questions

Domain Plan and implement data platform resources

Answer options
A: \\[]
B: % Correct answer
C: \\[]
D: @
Correct Answer:
B. %
Explanation

In Azure Databricks notebooks, a default language is set upon creation. To execute code in a different language within a specific cell, you must use a "magic command" at the beginning of the cell. These commands are prefixed with a percent sign (%) followed by the name of the language. For the scenario described, even though the notebook's default language is R, you would use %scala to run Scala code or %sql to run SQL queries in individual cells, effectively switching the language context for that specific cell.

Why Incorrect

A. \\[]: This syntax is not a valid command or switch for changing languages within an Azure Databricks notebook.
C. \\[]: This is a duplicate of option A and is also incorrect for the same reason.
D. @: The @ symbol is not used as a language switch in Azure Databricks. It has different meanings in other contexts, such as decorators in Python.

References

1. Microsoft Learn, Azure Databricks Documentation. "Databricks notebooks." Under the section "Mix languages," it states, "To override the default language in a cell, you can click the language button or type the language magic command % at the beginning of a cell." This explicitly confirms the use of the % symbol.

2. Microsoft Learn, Azure Databricks Documentation. "Magic commands." This document provides a comprehensive list of magic commands available in Databricks notebooks, all of which are prefixed with %. It lists %python, %r, %scala, and %sql as the primary language magic commands.

Scroll to Top