Recall & Review
beginner
What does the
current_date() function return in Apache Spark?The
current_date() function returns the current date as a DateType value without the time part.Click to reveal answer
beginner
How do you extract the year from a timestamp column in Spark?
Use the
year() function to get the year part from a timestamp or date column.Click to reveal answer
intermediate
What is the difference between
unix_timestamp() and to_timestamp() functions?unix_timestamp() returns the number of seconds since 1970-01-01 00:00:00 UTC as a long integer, while to_timestamp() converts a string to a timestamp type.Click to reveal answer
beginner
How can you add 5 days to a date column in Spark?
Use the
date_add(dateColumn, 5) function to add 5 days to the date in dateColumn.Click to reveal answer
beginner
What does the
datediff(end, start) function compute?It calculates the number of days between two dates:
end minus start.Click to reveal answer
Which function returns the current timestamp in Spark?
✗ Incorrect
current_timestamp() returns the current date and time as a timestamp.
How do you convert a string like '2024-06-01 12:30:00' to a timestamp in Spark?
✗ Incorrect
to_timestamp() converts a string to a timestamp type.
What does
date_sub(dateColumn, 3) do?✗ Incorrect
date_sub() subtracts days from a date.
Which function gives the number of seconds since 1970-01-01 00:00:00 UTC?
✗ Incorrect
unix_timestamp() returns seconds since epoch.
If you want to find the difference in days between two dates, which function do you use?
✗ Incorrect
datediff() calculates days between two dates.
Explain how to convert a string to a timestamp and then extract the year in Apache Spark.
Think about the functions to convert and then extract parts of a date.
You got /4 concepts.
Describe how to calculate the number of days between two date columns in Spark.
Focus on the function that measures days difference.
You got /3 concepts.