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…
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
- spark
- B
- spark
- C
- spark
- D
- spark
- E
- spark
How the community answered
(42 responses)- A2% (1)
- B81% (34)
- C10% (4)
- D5% (2)
- E2% (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
Community Discussion
No community discussion yet for this question.