Ultimate access to all questions.
As a data engineer, you are given a table named stores
that contains a column named city
, which holds string values representing the names of cities. You need to apply some custom logic to the city
column as part of a specific data processing use case. To implement this custom logic efficiently across the dataset within Databricks, you want to create a SQL user-defined function (UDF). Which of the following code blocks will allow you to create this SQL UDF?
Explanation:
The correct way to define a SQL user-defined function (UDF) in Databricks is by using the CREATE FUNCTION syntax. Option A follows this syntax correctly by creating a function named custom_logic, taking a string argument city, and returning the uppercase version of the input string. Other options either use incorrect syntax (e.g., CREATE UDF instead of CREATE FUNCTION) or incorrect logic (e.g., RETURNS CASE WHEN).