nerdexam
Databricks

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

In what order should the below lines of code be run in order to read a parquet at the file path filePath into a DataFrame? Lines of code: 1. storesDF 2. .load(filePath, source = "parquet") 3. .read \

The correct answer is C. 4, 3, 6. The idiomatic PySpark way to read a Parquet file is spark.read.parquet(filePath). Matching the numbered lines: Line 4 is spark, Line 3 is .read, and Line 6 is .parquet(filePath). The correct order is therefore 4 → 3 → 6. Line 5 (.read()) is incorrect because read is a property, n

Data Loading and Persistence

Question

In what order should the below lines of code be run in order to read a parquet at the file path filePath into a DataFrame? Lines of code: 1. storesDF 2. .load(filePath, source = "parquet") 3. .read \ 4. spark \ 5. .read() \ 6. .parquet(filePath)

Options

  • A1, 5, 2
  • B4, 5, 2
  • C4, 3, 6
  • D4, 5, 6
  • E4, 3, 2

How the community answered

(48 responses)
  • B
    4% (2)
  • C
    88% (42)
  • D
    2% (1)
  • E
    6% (3)

Explanation

The idiomatic PySpark way to read a Parquet file is spark.read.parquet(filePath). Matching the numbered lines: Line 4 is spark, Line 3 is .read, and Line 6 is .parquet(filePath). The correct order is therefore 4 → 3 → 6. Line 5 (.read()) is incorrect because read is a property, not a method - it must not be called with parentheses. Line 2 (.load(filePath, source='parquet')) is an alternative pattern using the generic loader but is not part of the shortest idiomatic chain. Line 1 (storesDF) would be an assignment target, not part of the read chain itself.

Topics

#SparkSession#DataFrameReader#Reading Parquet#Data Loading

Community Discussion

No community discussion yet for this question.

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