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

Which of the following code blocks returns a DataFrame containing a column month, an integer representation of the day of the year from column openDate from DataFrame storesDF.

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:

stored.withColumn(“openTimestamp”, col(“openDate”).cast(__1__))

.withColumn(__2__, __3__(__4__))

    Correct Answer: D

    The correct code involves converting the UNIX timestamp (openDate) to a format that can be used for extracting the month. To begin, the openDate column needs to be cast to a Timestamp type to work with date functions. Option D starts by casting openDate to a Timestamp, then correctly uses the 'month' function to extract the month from the Timestamp. This aligns with the requirement of producing a DataFrame containing a column with the month derived from the UNIX epoch format represented in openDate.

Discussion
SaiPavan10Option: D

D is the right choice

Sowwy1Option: D

It s D