Databricks Data Engineer Associate Question 99
Select 3You are working with a dataset stored in the file path '/mnt/data/sales_data.csv'. You want to allow other team members to run queries on this dataset without modifying the original file. Additionally, you need to create a temporary reference for your own session to perform ad hoc analysis. Which of the following options correctly describe how you can achieve this?
- A
Create a global temporary view using the command:
CREATE OR REPLACE GLOBAL TEMP VIEW sales_view AS SELECT * FROM csv.'mnt/data/sales_data.csv'. - B
Create a temporary view using the command:
CREATE OR REPLACE TEMP VIEW sales_view AS SELECT * FROM csv.'mnt/data/sales_data.csv'. - C
Create a common table expression (CTE) using the syntax:
WITH sales_cte AS (SELECT * FROM csv.'mnt/data/sales_data.csv') SELECT * FROM sales_cte;. - D
Create a standard view using the command:
CREATE OR REPLACE VIEW sales_view AS SELECT * FROM csv.'mnt/data/sales_data.csv'.
Show answer and explanation
Correct answers: B, C, D
Explanation
To create temporary or persistent references to a file in Databricks, you can use temporary views, common table expressions (CTEs), or standard views. Temporary views are session-specific and ideal for ad hoc analysis, while standard views are persistent and can be used by others. CTEs are query-specific constructs for creating temporary references within a single SQL statement. Global temporary views are not suitable in this scenario due to incorrect syntax and the session-independent nature of such views.
- A. Incorrect.
This option is incorrect because global temporary views are not created using the specified syntax. Additionally, global temporary views are session-independent and not suitable for ad hoc analysis.
- B. Correct.
This option is correct because temporary views are session-specific and allow you to perform ad hoc analysis without persisting the changes.
- C. Correct.
This option is correct because a common table expression (CTE) allows you to create a temporary reference to the file for use within a specific query, meeting the requirement for ad hoc analysis.
- D. Correct.
This option is correct because creating a standard view allows other team members to run queries on the dataset without modifying the original file, as views are persistent database objects.