Skip to main content
PYSPARK • LESSON 97

Filtering Unmatched Rows with Anti Join

How do we find customers who have NOT placed any recent orders using a left_anti join?

Advanced2 Minutes500 XP
🤔 THE QUESTION

How do we find customers who have NOT placed any recent orders using a left_anti join?

💡 WHAT IS IT?

left_anti returns only records from the left DataFrame that have NO match in the right DataFrame.

🎯 WHAT IS IT USED FOR?

Customer churn detection, finding orphaned foreign keys, and identifying missing data syncs.

💻 EXAMPLE
churned_customers = customers.join(recent_orders, "customer_id", "left_anti")

🎯 Mission Objectives

Practice typing production-grade PySpark code for Filtering Unmatched Rows with Anti Join.

  • Execute left_anti join
  • Isolate churned or inactive customers
  • Exclude matching transactional records