QuestionQ58

VerifiedData Processing & Transformations

A data engineer must apply custom logic to the string column city in the stores table for a particular use case. To apply this custom logic at scale, the data engineer wants to create a SQL user-defined function (UDF).

Which of the following code blocks creates this SQL UDF?

Explanation

A Databricks SQL scalar UDF is created with CREATE FUNCTION, a typed parameter list, an optional RETURNS data type, and a RETURN expression. CASE WHEN city = "brooklyn" THEN "new york" ELSE city END is a valid scalar expression that returns a string, so this definition correctly implements the required logic.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!