Microsoft Certified Azure Data Engineer Associate · Free Practice Question Medium
Question 17
Scenario: You are working in an Azure Databricks workspace and you want to filter based on the end of a column value using the Column Class. Specifically, you are looking at a column named verb and filtered by words ending with "ing".
Which command filters based on the end of a column value as required?
-
A
df.filter("verb like ‘_ing'") -
B
df.filter(col("verb").endswith("ing")) -
C
df.filter().col("verb").like("%ing")
Reveal correct answer
Correct answer: B
Explanation
The Column Class supports both the endswith() method and the like() method (example - col("verb").like("%ing")).
A. This choice is incorrect. The syntax provided ("verb like ‘_ing’") is not suitable for filtering based on the end of a column value in Azure Databricks. The underscore _ is used as a wildcard for a single character, not for the end of a value.
B. The correct choice. In Azure Databricks, the endswith function is used to filter based on the end of a column value. By using col("verb").endswith("ing"), you are specifically filtering the column named "verb" for values that end with "ing".
C. This choice is incorrect. The like function with the % wildcard is used for pattern matching in SQL queries, not for filtering based on the end of a column value in Azure Databricks.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
