Databricks-Spark-Assoc Developing DataFrame/DataSet API Applications Practice Question
A data engineer has a DataFrame `orders` with columns `order_id`, `customer_id`, and `amount`, and a small lookup DataFrame `tiers` with `customer_id` and `tier`. The engineer wants to attach the tier to every order. Some orders have a customer_id that is not present in tiers, and those orders must still appear with a null tier. Which operation produces this result?
⚠ Common exam trap
It's easy for candidates to confuse which side an outer join preserves, so a right join looks similar but actually retains the lookup rows and discards unmatched orders.
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
✓
orders.join(tiers, on="customer_id", how="left")
The requirement is to keep all orders while enriching them with tier where available, filling null otherwise. A left outer join does precisely this: it preserves the left side unconditionally and matches right-side rows on the key, leaving nulls for misses. Inner join drops unmatched orders, right join preserves the wrong side, and union performs no key-based matching at all.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
orders.join(tiers, on="customer_id", how="inner")
Why it's wrong here
An inner join keeps only rows whose keys match in both DataFrames, so orders with a customer_id absent from tiers would be dropped entirely. The scenario requires those unmatched orders to remain with a null tier, which is the defining behavior of an outer join. Inner join therefore fails the stated requirement even though it is otherwise a valid join type.
- ✗
orders.union(tiers)
Why it's wrong here
union concatenates rows and requires compatible schemas, whereas orders and tiers have different columns and represent different entities. Even after aligning columns, union performs no key matching, so it could not attach the correct tier to each order. It would produce a combined row set rather than the joined result the scenario describes, and would fail on schema mismatch.
- ✗
orders.join(tiers, on="customer_id", how="right")
Why it's wrong here
A right outer join preserves every row from tiers and drops unmatched left rows, which is the opposite of what is needed. Orders with no matching customer_id would disappear, and tiers with no orders would appear with nulls instead. This inverts the preservation direction and therefore does not satisfy keeping all orders with a null tier where unmatched.
- ✓
orders.join(tiers, on="customer_id", how="left")
Why this is correct
A left outer join preserves every row from the left DataFrame and fills columns from the right with nulls when no match exists. That is exactly the required behavior: all orders remain, and orders whose customer_id is missing from tiers get a null tier. The join key is shared, so the output contains one customer_id column plus order_id, amount, and tier.
About these practice questions
One of 295 original Databricks-Spark-Assoc practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.