CERTIFIED-DATA-ENGINEER-PROFESSIONAL · Question #9
A junior member of the data engineering team is exploring the language interoperability of Databricks notebooks. The intended outcome of the below code is to register a view of all sales that occurred
The correct answer is E. Cmd 1 will succeed and Cmd 2 will fail, countries at will be a Python variable containing a list of. This is the correct answer because Cmd 1 is written in Python and uses a list comprehension to extract the country names from the geo_lookup table and store them in a Python variable named countries af. This variable will contain a list of strings, not a PySpark DataFrame or a SQ
Question
A junior member of the data engineering team is exploring the language interoperability of Databricks notebooks. The intended outcome of the below code is to register a view of all sales that occurred in countries on the continent of Africa that appear in the geo_lookup table. Before executing the code, running SHOW TABLES on the current database indicates the database contains only two tables: geo_lookup and sales. Which statement correctly describes the outcome of executing these command cells in order in an interactive notebook?
Exhibit
Options
- ABoth commands will succeed. Executing show tables will show that countries at and sales at have
- BCmd 1 will succeed. Cmd 2 will search all accessible databases for a table or view named
- CCmd 1 will succeed and Cmd 2 will fail, countries at will be a Python variable representing a
- DBoth commands will fail. No new variables, tables, or views will be created.
- ECmd 1 will succeed and Cmd 2 will fail, countries at will be a Python variable containing a list of
How the community answered
(30 responses)- B3% (1)
- C13% (4)
- D7% (2)
- E77% (23)
Explanation
This is the correct answer because Cmd 1 is written in Python and uses a list comprehension to extract the country names from the geo_lookup table and store them in a Python variable named countries af. This variable will contain a list of strings, not a PySpark DataFrame or a SQL view. Cmd 2 is written in SQL and tries to create a view named sales af by selecting from the sales table where city is in countries af. However, this command will fail because countries af is not a valid SQL entity and cannot be used in a SQL query. To fix this, a better approach would be to use spark.sql() to execute a SQL query in Python and pass the countries af variable as a
Topics
Community Discussion
No community discussion yet for this question.
