nerdexam
Databricks

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

The code block shown below contains an error. The code block intended to return a new DataFrame that is the result of an inner join between DataFrame storesDF and DataFrame employeesDF on column…

The correct answer is C. The default argument to the joinType parameter is "inner" - an additional argument of "left" must. Option C is correct because StoresDF uses a capital "S" while the actual DataFrame variable is named storesDF - both Scala and Python are case-sensitive, so this would cause a NameError at runtime. The .join() call itself is syntactically valid; Spark's default joinType is…

DataFrame Join Syntax and Parameters in Apache Spark

Question

The code block shown below contains an error. The code block intended to return a new DataFrame that is the result of an inner join between DataFrame storesDF and DataFrame employeesDF on column storeId. Identify the error. Code block:

StoresDF.join(employeesDF, Seq("storeId")

Options

  • AThe key column storeId needs to be a string like "storeId".
  • BThe key column storeId needs to be specified in an expression of both Data Frame columns like
  • CThe default argument to the joinType parameter is "inner" - an additional argument of "left" must
  • DThere is no DataFrame.join() operation - DataFrame.merge() should be used instead.
  • EThe key column storeId needs to be wrapped in the col() operation.

How the community answered

(26 responses)
  • A
    4% (1)
  • B
    8% (2)
  • C
    88% (23)

Explanation

Option C is correct because StoresDF uses a capital "S" while the actual DataFrame variable is named storesDF - both Scala and Python are case-sensitive, so this would cause a NameError at runtime. The .join() call itself is syntactically valid; Spark's default joinType is already "inner", meaning no third argument is required to get an inner join.

Why the distractors are wrong:

  • A is wrong because "storeId" inside Seq("storeId") is already a string - no change needed there.
  • B is wrong because the Seq("storeId") shorthand (joining on a shared column name) is a perfectly valid alternative to writing a full column expression like storesDF("storeId") === employeesDF("storeId").
  • D is wrong because DataFrame.join() absolutely exists in Spark; .merge() is a pandas method and does not apply here.
  • E is wrong because col() wrapping is only needed when you pass a column expression, not when using the Seq / string shorthand for join keys.

Memory tip: Whenever a code snippet looks almost right but throws an unexpected error, check variable name casing first - Spark (Scala/Python) is case-sensitive, and a mismatched StoresDF vs storesDF is a classic exam trap. Remember: default join = inner, so no third argument needed.

Topics

#Spark DataFrames#Join Operations#DataFrame API#SQL Operations

Community Discussion

No community discussion yet for this question.

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