nerdexam
Databricks

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

Perform data manipulation and transformations using Spark DataFrames

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)
  • A
    88% (46)
  • B
    2% (1)
  • C
    2% (1)
  • E
    8% (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

#DataFrame operations#Joins#Data Transformation#Spark SQL

Community Discussion

No community discussion yet for this question.

Full DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice