Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this exam
Question 88

The code block shown below contains an error. The code block intended to return a DataFrame containing a column dayOfYear, an integer representation of the day of the year from column openDate from DataFrame storesDF. Identify the error.

Note that column openDate is of type integer and represents a date in the UNIX epoch format – the number of seconds since midnight on January 1st, 1970.

A sample of storesDF is displayed below:

Code block:

storesDF.withColumn("dayOfYear", dayofyear(col("openDate")))

    Correct Answer: A

    The dayofyear() operation requires the input column to be of type Timestamp. Given that the openDate column in storesDF is of type integer which represents the number of seconds since the UNIX epoch, this column must first be converted to a Timestamp type before the dayofyear() function can accurately extract the day of the year.

Discussion
tangerine141Option: A

A is correct

newusernameOption: A

A is correct

kaisa1234

But question 50 is the same question and states that the code block with an error is the correct

newusername

the answer there is wrong. I posted the correct one.