Databricks Certified Associate Developer for Apache Spark — Question 141
Which of the following code blocks returns a new DataFrame that is the result of a position-wise union between DataFrame storesDF and DataFrame acquiredStoresDF?
Answer options
- A. storesDF.unionByName(acquiredStoresDF)
- B. unionAll(storesDF, acquiredStoresDF)
- C. union(storesDF, acquiredStoresDF)
- D. concat(storesDF, acquiredStoresDF)
- E. storesDF.union(acquiredStoresDF)
Correct answer: E
Explanation
The correct answer, E, uses the union method to combine the two DataFrames. Option A, while valid for combining DataFrames, does so by matching column names instead of positions. Options B and C are incorrect as they do not represent valid methods to perform a union in this context, and D uses concat, which does not perform a union but rather concatenates the DataFrames.