DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #162
Which of the following operations can be used to perform a left join on two DataFrames?
The correct answer is A. DataFrame.join(). DataFrame.join() is the correct and only valid option. It accepts an optional how parameter to specify the join type, e.g., storesDF.join(employeesDF, 'storeId', how='left'). crossJoin() only performs cartesian cross joins and has no how parameter. merge() is a pandas method, not
Question
Which of the following operations can be used to perform a left join on two DataFrames?
Options
- ADataFrame.join()
- BDataFrame.crossJoin()
- CDataFrame.merge()
- DDataFrame.leftJoin()
- EStandalone join() function
How the community answered
(52 responses)- A88% (46)
- B2% (1)
- C2% (1)
- E8% (4)
Explanation
DataFrame.join() is the correct and only valid option. It accepts an optional how parameter to specify the join type, e.g., storesDF.join(employeesDF, 'storeId', how='left'). crossJoin() only performs cartesian cross joins and has no how parameter. merge() is a pandas method, not a PySpark DataFrame method. leftJoin() does not exist in the PySpark API. There is no standalone join() function in PySpark's standard DataFrame API. Only DataFrame.join() supports left, right, inner, outer, semi, and anti joins via the how argument.
Topics
Community Discussion
No community discussion yet for this question.