Databricks Data Engineer Associate Question 507
Single answerYou are working with a Databricks platform where data is organized using a three-layer namespace: catalog, schema, and table. How would you query a table named 'sales' that resides in the 'retail' schema of the 'analytics' catalog?
- A
SELECT * FROM sales
- B
SELECT * FROM retail.sales
- C
SELECT * FROM analytics.retail.sales
- D
SELECT * FROM analytics.sales.retail
Show answer and explanation
Correct answer: C
Explanation
In Databricks, the three-layer namespace follows the structure catalog.schema.table. When querying a table in this type of namespace, you must specify all three layers in the correct order. The correct syntax to query the 'sales' table in the 'retail' schema of the 'analytics' catalog is 'analytics.retail.sales'.
- A. Incorrect.
This query is incorrect because it does not reference the catalog or schema, which are required in a three-layer namespace.
- B. Incorrect.
This query is incorrect because it only references the schema and table, but does not include the catalog.
- C. Correct.
This query is correct because it fully qualifies the table using the three-layer namespace: catalog.schema.table.
- D. Incorrect.
This query is incorrect because it references the catalog, table, and schema in the wrong order.