QuestionQ16

VerifiedDeveloping Code for Data Processing using Python and SQL

A junior data-engineering team member is investigating language interoperability in Databricks notebooks. The desired result of the code below is to register a view containing all sales made in countries from the continent of Africa that are present in the geo_lookup table.

Before the code is run, SHOW TABLES in the current database shows that it contains only two tables: geo_lookup and sales.

Question Image

Which statement accurately describes the result of running these command cells sequentially in an interactive notebook?

Explanation

DataFrame.collect() returns a Python list of Row objects, and indexing each row with [0] produces a Python list of country strings. This does not register a Spark SQL table or view. A subsequent SQL cell cannot use that Python list as the unquoted countries_af operand in an IN predicate, so the CREATE VIEW statement fails.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!