nerdexam
Databricks

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

The code block shown below contains an error. The code block intended to read a parquet at the file path filePath into a DataFrame. Identify the error. Code block: spark.read.load(filePath, source…

The correct answer is E. There is no source parameter to the load() operation - it can be removed. The DataFrameReader.load() method does not have a source parameter - the valid parameters are path, format, schema, and **options. Using source="parquet" (or source - "parquet" as written, which is also a syntax error using - instead of =) will be silently ignored or raise an…

Data Ingestion and Output with Apache Spark DataFrames

Question

The code block shown below contains an error. The code block intended to read a parquet at the file path filePath into a DataFrame. Identify the error. Code block:

spark.read.load(filePath, source - "parquet")

Options

  • AThere is no source parameter to the load() operation - the schema parameter should be used
  • BThere is no load() operation - it should be parquet() instead.
  • CThe spark.read operation should be followed by parentheses to return a DataFrameReader
  • DThe filePath argument to the load() operation should be quoted.
  • EThere is no source parameter to the load() operation - it can be removed.

How the community answered

(30 responses)
  • C
    3% (1)
  • D
    7% (2)
  • E
    90% (27)

Explanation

The DataFrameReader.load() method does not have a source parameter - the valid parameters are path, format, schema, and **options. Using source="parquet" (or source - "parquet" as written, which is also a syntax error using - instead of =) will be silently ignored or raise an error depending on the Spark version. To read parquet with load(), either use spark.read.format("parquet").load(filePath) or the shortcut spark.read.parquet(filePath). The source argument can simply be removed when using the format-specific .parquet() method.

Topics

#Spark DataFrames#Data Ingestion#Reading Parquet#Spark API Usage

Community Discussion

No community discussion yet for this question.

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