Databricks Data Engineer Associate Question 110
Select 3You are tasked with creating a Delta table in Databricks. The data comes from two sources: a remote MySQL database accessible via JDBC and an external CSV file stored in an Azure Data Lake. What steps should you take to successfully create the table from both sources?
- A
Use the
spark.read.format('jdbc')method to load data from the MySQL database and write it to a Delta table. - B
Use the
spark.read.csv()method to load the CSV file and save it as a Delta table usingdeltaformat. - C
Directly query the MySQL database in a SQL cell and save the results as a Delta table using the
CREATE TABLE ... USING DELTAcommand. - D
Mount the Azure Data Lake storage using Databricks and then use
spark.read.format('csv')to access the CSV file. - E
Combine the data from the JDBC source and the CSV file in a DataFrame and write the resulting DataFrame as a Delta table.
Show answer and explanation
Correct answers: A, B, E
Explanation
To create a Delta table in Databricks from multiple sources (JDBC and CSV), you must use the appropriate Spark APIs to read data into DataFrames. The spark.read.format('jdbc') method is used for JDBC sources, and spark.read.csv() is used for CSV files. After loading the data, you can combine the DataFrames if needed, and write the resulting DataFrame to a Delta table using the .write.format('delta') method. Direct SQL commands or simply mounting storage do not automatically create Delta tables.
- A. Correct.
Correct. The
spark.read.format('jdbc')method is the appropriate way to load data from a JDBC source, such as a MySQL database, into a DataFrame in Databricks. This DataFrame can then be written to a Delta table. - B. Correct.
Correct. The
spark.read.csv()method is the correct approach to load data from an external CSV file into a DataFrame, which can then be written to a Delta table in Databricks. - C. Incorrect.
Incorrect. While it is possible to query a JDBC source using SQL in Databricks, saving the results directly as a Delta table using
CREATE TABLE ... USING DELTAis not supported. You need to use Spark APIs to write the data to Delta format. - D. Incorrect.
Incorrect. Mounting Azure Data Lake storage is a valid step to access the CSV file, but this step alone does not create a Delta table. You must explicitly read the file and write it in Delta format.
- E. Correct.
Correct. Combining data from multiple sources into a single DataFrame and then writing it to a Delta table is a valid approach in Databricks.