Exam Associate-Developer-Apache-Spark-3.5 Topic 3 Question 128 Discussion
Actual exam question for Databricks's Associate-Developer-Apache-Spark-3.5 exam
Question #: 128
Topic #: 3
Question #: 128
Topic #: 3
Given a CSV file with the content:

And the following code:
from pyspark.sql.types import *
schema = StructType([
StructField("name", StringType()),
StructField("age", IntegerType())
])
spark.read.schema(schema).csv(path).collect()
What is the resulting output?

And the following code:
from pyspark.sql.types import *
schema = StructType([
StructField("name", StringType()),
StructField("age", IntegerType())
])
spark.read.schema(schema).csv(path).collect()
What is the resulting output?
Suggested Answer: C Vote an answer
In Spark, when a CSV row does not match the provided schema, Spark does not raise an error by default. Instead, it returns null for fields that cannot be parsed correctly.
In the first row, "hello" cannot be cast to Integer for the age field → Spark sets age=None In the second row, "20" is a valid integer → age=20 So the output will be:
[Row(name='bambi', age=None), Row(name='alladin', age=20)]
Final answer: C
In the first row, "hello" cannot be cast to Integer for the age field → Spark sets age=None In the second row, "20" is a valid integer → age=20 So the output will be:
[Row(name='bambi', age=None), Row(name='alladin', age=20)]
Final answer: C
by pankaj.k.shukla at Sep 28, 2026, 11:55 AM
0
0
0
10
Comments
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Report Comment
Commenting
You can sign-up / login (it's free).