Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Certified Associate Developer for Apache Spark topic 1 question 89 discussion

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")))

  • A. The dayofyear() operation cannot extract the day of year from a column of type integer – column openDate must first be converted to type Timestamp.
  • B. The dayofyear() operation takes a quoted column name rather than a Column object as its first argument – the first argument should be "openDate".
  • C. The dayofyear() operation cannot extract the day of year from a column of type integer – column openDate must first be converted to type Date.
  • D. The dayofyear() operation is not applicable in a withColumn() call – the newColumn() operation must be used instead.
  • E. There is no dayofyear() operation – the day of year number must be extracted using substring utilities.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
tangerine141
3 months, 3 weeks ago
Selected Answer: A
A is correct
upvoted 1 times
...
newusername
7 months, 1 week ago
Selected Answer: A
A is correct
upvoted 1 times
...
kaisa1234
8 months, 4 weeks ago
But question 50 is the same question and states that the code block with an error is the correct
upvoted 1 times
newusername
7 months, 1 week ago
the answer there is wrong. I posted the correct one.
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

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.

SaveCancel
Loading ...