Databricks Data Engineer Associate Question 508
Single answerYou are tasked with querying a table named sales_data stored in a three-layer namespace structure (database.schema.table) within a Databricks workspace. The table resides in the retail database under the analytics schema. Which of the following queries will correctly retrieve all records from this table?
- A
SELECT * FROM retail.analytics.sales_data;
- B
SELECT * FROM analytics.retail.sales_data;
- C
SELECT * FROM sales_data;
- D
SELECT * FROM retail.sales_data;
Show answer and explanation
Correct answer: A
Explanation
In Databricks, a three-layer namespace structure (database.schema.table) is used to organize and query tables. The correct syntax to query a table from this structure is SELECT * FROM database.schema.table. Failing to include all layers of the namespace or using them in the incorrect order will result in an error or unexpected behavior.
- A. Correct.
This is the correct query format for accessing a table in a three-layer namespace structure, where
database.schema.tableis specified. - B. Incorrect.
This is incorrect because the order of the namespace layers is reversed. The correct order is
database.schema.table. - C. Incorrect.
This is incorrect because it does not use the fully qualified namespace. Without specifying the database and schema, the query will fail if the table does not exist in the default catalog.
- D. Incorrect.
This is incorrect because it omits the schema layer, which is required when using a three-layer namespace structure.