Databricks Certified Associate Developer For Apache Spark 30 · Free Practice Question Medium
Question 8
You have a need to sort a dataframe df which has some null values on column a. You want the null values to appear last, and then the rest of the rows should be ordered ascending based on the column a. Choose the right code block to achieve your goal.
-
A
df.orderBy(asc_nulls_last(a)) - B It is not possible to sort, when there are null values on the specified column.
-
C
df.orderBy(df.a.asc_nulls_last()) -
D
df.orderBy(asc("a")) -
E
df.sort(asc_nulls_last(a))
Reveal correct answer
Correct answer: C
Explanation
Correct syntax is;
df.orderBy(df.a.asc_nulls_last())
df.sort(df.a.asc_nulls_last())
or
df.orderBy(asc_nulls_last("a"))
df.sort(asc_nulls_last("a"))
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
