nerdexam
Databricks

DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #63

The code block shown below should return a new DataFrame that is the result of an outer join between DataFrame storesDF and DataFrame employeesDF on column storeId. Choose the response that…

The correct answer is E. 1. join. Option E is correct because PySpark DataFrames use the join method with the signature join(other, on, how) - making the correct call storesDF.join(employeesDF, "storeId", "outer"), where the second argument is the other DataFrame, the third is the join key as a string, and the…

DataFrame Transformation Methods - Join Operations

Question

The code block shown below should return a new DataFrame that is the result of an outer join between DataFrame storesDF and DataFrame employeesDF on column storeId. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block:

storesDF.1(2, 3, 4)

Options

  • A
    1. join
  • B
    1. merge
  • C
    1. join
  • D
    1. merge
  • E
    1. join

How the community answered

(31 responses)
  • A
    3% (1)
  • B
    6% (2)
  • D
    3% (1)
  • E
    87% (27)

Explanation

Option E is correct because PySpark DataFrames use the join method with the signature join(other, on, how) - making the correct call storesDF.join(employeesDF, "storeId", "outer"), where the second argument is the other DataFrame, the third is the join key as a string, and the fourth specifies the join type.

Options B and D are wrong because merge is a pandas method, not a PySpark DataFrame method - using it on a Spark DataFrame will raise an AttributeError.

Options A and C also use join, but likely have the parameters in the wrong order (e.g., swapping "storeId" and "outer", or passing the column name unquoted) - PySpark requires the join key before the join type, and string literals must be quoted.

Memory tip: Think "Spark JOINs, Pandas MERGEs." In PySpark, join follows SQL-like argument order: who, what column, what type - just like writing JOIN employeesDF ON storeId OUTER in SQL.

Topics

#DataFrame joins#PySpark API#Join syntax#Outer joins

Community Discussion

No community discussion yet for this question.

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