Databricks Data Engineer Associate Question 100
Select 3You are working with a large CSV file stored in a Databricks workspace. You need to reference this file in multiple queries during your session, and later make one of the references persist for future use. Which of the following steps should you take?
- A
Use
CREATE OR REPLACE VIEWto create a view referencing the file. - B
Use
CREATE TEMPORARY VIEWto create a temporary view referencing the file. - C
Use a Common Table Expression (CTE) to temporarily reference the file within a specific query.
- D
Use
CREATE GLOBAL TEMP VIEWto create a globally accessible view referencing the file. - E
Use
INSERT INTOto load the file into a new table and reference it directly.
Show answer and explanation
Correct answers: A, B, C
Explanation
To reference a file in Databricks, you can use a view, a temporary view, or a CTE depending on the scope of usage. A persistent view (created using CREATE OR REPLACE VIEW) is suitable if you need a reusable reference for future queries. A temporary view (CREATE TEMPORARY VIEW) is ideal for session-specific tasks. A CTE is appropriate for a single query. Using a global temporary view or loading the file into a table is unnecessary unless explicitly required by additional use cases.
- A. Correct.
Correct. A view created using
CREATE OR REPLACE VIEWis persistent and allows you to reference the file for future use. - B. Correct.
Correct. A temporary view created using
CREATE TEMPORARY VIEWis valid for the duration of the session and works well for session-specific tasks. - C. Correct.
Correct. A CTE is a great choice for referencing the file within a single query, but it is not persistent beyond that query.
- D. Incorrect.
Incorrect. While
CREATE GLOBAL TEMP VIEWcreates a globally accessible view, it is not needed in this scenario as the problem does not specify global accessibility requirements. - E. Incorrect.
Incorrect. Loading the file into a new table is not necessary in this case because the requirement is to reference the file, not to permanently store it in a table.