
Answer-first summary for fast verification
Answer: SELECT geo.country FROM events WHERE geo.country = ‘India‘
Spark SQL provides a robust syntax for interacting with complex and nested data types. The geo field in the events table is a struct that includes city, state, and country subfields, all of string type. To access these subfields, you use the standard dot notation: `field_name.subfield_name`. Therefore, the correct query is: `SELECT geo.country FROM events WHERE geo.country = ‘India’`.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
As a data engineer, you're tasked with querying data from an e-commerce website's events table, which includes a geo field of struct type containing a country subfield. How would you correctly query the data based on the country subfield?
A
SELECT geo:country FROM events WHERE geo:country = ‘India‘
B
SELECT geo*country FROM events WHERE geo*country = ‘India‘
C
SELECT country FROM events WHERE country = ‘India‘
D
SELECT geo.country FROM events WHERE geo.country = ‘India‘
E
SELECT struct.country FROM events WHERE struct.country = ‘India‘