Databricks-Spark-Assoc Using Spark SQL Practice Question
A data engineer has two Spark SQL DataFrames: customers (customer_id, name) and orders (order_id, customer_id, amount). They want to retrieve every customer along with their orders, but they also want to include customers who have placed no orders, showing null for the order columns. Which operation should they use?
⚠ Common exam trap
The trap here is mixing up left and right outer joins by focusing on the table that has more rows rather than on which DataFrame must be fully preserved.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
customers.join(orders, customers.customer_id == orders.customer_id, 'left')
A left outer join preserves every row from the customers DataFrame while attaching matching order rows, so customers without orders appear with nulls in the order columns. Inner, right, and full outer joins either drop unmatched customers or add unmatched orders, so they do not meet the stated requirement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
customers.join(orders, customers.customer_id == orders.customer_id, 'full')
Why it's wrong here
A full outer join keeps all rows from both sides, including unmatched orders that have no corresponding customer. The scenario only asks to retain all customers, not all orders. Using a full outer join would introduce extra rows with null customer information, which is beyond the stated requirement.
- ✗
customers.join(orders, customers.customer_id == orders.customer_id, 'inner')
Why it's wrong here
An inner join returns only rows where the join key matches in both DataFrames. Customers without orders would be excluded entirely, so the result would not include those customers with null order columns. This contradicts the requirement to retain all customers, including those with no orders.
- ✓
customers.join(orders, customers.customer_id == orders.customer_id, 'left')
Why this is correct
A left outer join keeps all rows from the left DataFrame, customers, and matches rows from orders where possible. Customers with no orders appear with null values in the order columns, which is exactly the desired behavior. This satisfies the requirement to include every customer while optionally attaching their orders.
- ✗
customers.join(orders, customers.customer_id == orders.customer_id, 'right')
Why it's wrong here
A right outer join retains all rows from the right DataFrame, orders, and matches from customers. Customers with no orders are dropped, and any orders with no matching customer would be kept instead. This is the opposite of what the scenario requires, since the goal is to preserve all customers.
About these practice questions
This Databricks-Spark-Assoc question is part of Courseiva's 295-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Databricks exam blueprint
This Databricks-Spark-Assoc practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-Spark-Assoc exam.