QuestionQ214

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

A developer is attempting to join the two tables sales.purchases_fct and sales.customer_dim with the following code:

Question Image

The developer finds that customers in the purchases_fct table that are absent from the customer_dim table are being excluded from the joined table.

What change should be made to the code to prevent these customer records from being dropped?

Explanation

DataFrame.join() defaults to an inner join when no join type is specified, so rows without a match are excluded. A left join retains all rows from purch_df—the left-side purchases_fct DataFrame—and includes null values for unmatched cust_df columns. The left join type is supported by PySpark’s DataFrame.join() API.

Learn more

Community Discussion

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