nerdexam
Databricks

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

Which of the following pairs of arguments cannot be used in DataFrame.join() to perform an inner join on two DataFrames, named and aliased with "a" and "b" respectively, to specify two key columns…

The correct answer is B. usingColumns = Seq(col("column1"), col("column2")). Option B is the correct answer because usingColumns in DataFrame.join() accepts a Seq[String] (a sequence of plain string column names), not a Seq[Column] - passing col("column1") objects instead of "column1" strings will cause a compile-time type error in Spark. Why the…

Understand DataFrame join syntax and parameter requirements

Question

Which of the following pairs of arguments cannot be used in DataFrame.join() to perform an inner join on two DataFrames, named and aliased with "a" and "b" respectively, to specify two key columns column1 and column2?

Options

  • AjoinExprs = col("a.column1") === col("b.column1") and col("a.column2") === col("b.column2")
  • BusingColumns = Seq(col("column1"), col("column2"))
  • CAll of these options can be used to perform an inner join with two key columns.
  • DjoinExprs = storesDF("column1") === employeesDF("column1") and storesDF("column2") ===
  • EusingColumns = Seq("column1", "column2")

How the community answered

(50 responses)
  • A
    2% (1)
  • B
    92% (46)
  • C
    2% (1)
  • D
    4% (2)

Explanation

Option B is the correct answer because usingColumns in DataFrame.join() accepts a Seq[String] (a sequence of plain string column names), not a Seq[Column] - passing col("column1") objects instead of "column1" strings will cause a compile-time type error in Spark.

Why the distractors are wrong:

  • A is valid: when DataFrames are aliased (e.g., df.as("a")), you can use col("a.column1") in a joinExprs boolean expression combined with && or and.
  • D is valid: storesDF("column1") is another legal way to reference a DataFrame's column inside a joinExprs expression; Spark resolves it unambiguously.
  • E is valid: usingColumns = Seq("column1", "column2") is exactly the correct syntax - strings, not col() wrappers.
  • C is wrong precisely because B is invalid, so not all options work.

Memory tip: Think of usingColumns as the "simple strings" path - it handles column name matching automatically so you don't need col(). If you want fine-grained control with col() objects, you must switch to the joinExprs signature instead.

Topics

#DataFrame.join()#Join expressions#API parameter types#Column references

Community Discussion

No community discussion yet for this question.

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