nerdexam
Databricks

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

The code block shown below should read a CSV at the file path filePath into a DataFrame with the specified schema schema. Choose the response that correctly fills in the numbered blanks within the…

The correct answer is B. 1. spark. The complete code block to read a CSV with a specified schema is: spark.read.schema(schema).format('csv').load(filePath). Filling in the blanks: (1) spark, (2) read, (3) schema, (4) schema (the variable), (5) load, (6) filePath. The schema() method enforces the column types…

Loading Data into DataFrames

Question

The code block shown below should read a CSV at the file path filePath into a DataFrame with the specified schema schema. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block:

1.2.3(4).format("csv").5(6)

Options

  • A
    1. spark
  • B
    1. spark
  • C
    1. spark
  • D
    1. spark
  • E
    1. spark

How the community answered

(42 responses)
  • A
    2% (1)
  • B
    81% (34)
  • C
    10% (4)
  • D
    5% (2)
  • E
    2% (1)

Explanation

The complete code block to read a CSV with a specified schema is: spark.read.schema(schema).format('csv').load(filePath). Filling in the blanks: (1) spark, (2) read, (3) schema, (4) schema (the variable), (5) load, (6) filePath. The schema() method enforces the column types instead of relying on inference. format('csv') tells Spark to use the CSV data source, and load(filePath) specifies the file location. Choice B is the only option that provides all six blanks correctly in this sequence.

Topics

#Spark DataFrame API#Data Ingestion#CSV Data Source#Schema Definition

Community Discussion

No community discussion yet for this question.

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