Exam Certified Data Engineer Associate All QuestionsBrowse all questions from this exam
Question 17

A data engineer needs to apply custom logic to string column city in table stores for a specific use case. In order 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?

    Correct Answer: A

    To create a SQL user-defined function (UDF) in Databricks, the correct syntax involves using the CREATE FUNCTION statement followed by the definition of the function's parameters, its return type, and the logic implemented in the function body. The correct syntax is exemplified by CREATE FUNCTION <function_name>(<parameter> <parameter_type>) RETURNS <return_type> <body>. The option provided presents a function named custom_logic, which takes a string parameter city, returns a string, and includes sample logic to return the uppercase version of the city. This reflects the proper approach for creating a SQL UDF.

Discussion
FlexronOption: A

E is wrong, the right answer is A. https://www.databricks.com/blog/2021/10/20/introducing-sql-user-defined-functions.html

XiltroXOption: A

The answer E is incorrect. A user defined function is never written as CREATE UDF. The correct way is CREATE FUNCTION. So that leaves us with the choices A and D. Out of that, in D, there is no such thing as RETURN CASE so the correct answer is A.

Redwings538

Both A and D use RETURN CASE

HuroyeOption: A

Correct answer is A. It is not E. First, you do not need to specify "UDF" in the syntax. You need to specify the return type and then what you want to return, usually your processed output. CREATE FUNCTION myUDF(udf STRING) RETURNS STRING <...udf....>

agAshishOption: D

D, should be the answer. The fucntion is not returning STRING , it is applied on a string column

DavidRouOption: A

A is the right answer. The template to use is the following: CREATE FUNCTION <name_function> (<function_parameter>, ..) RETURNS <return_type> <body>

3fbc31bOption: A

A is the correct syntax for creating a UDF in Databricks.

benni_aleOption: A

A is correct

a_51Option: A

https://docs.databricks.com/en/udf/index.html#language-sql Answer E is not correct when having CREATE UDF rather than CREATE FUNCTION

isamrat28Option: A

Correct Answer is A

SerGreyOption: A

Correct answer is A

VijayKulaOption: A

Create Function Return String

VijayKulaOption: A

Correct is A

AtanuChat

First need create a function and then need to register it as UDF

KalavathiPOption: A

A is correct

d_b47Option: A

no UDF only FUNCTION needed.

akk_1289Option: A

CORRECT ANSWER IS : A https://www.databricks.com/blog/2021/10/20/introducing-sql-user-defined-functions.html

AtnafuOption: A

A -- Create the UDF CREATE FUNCTION custom_logic(city STRING) RETURNS STRING BEGIN -- Custom logic goes here -- Example: Return the uppercase version of the city RETURN UPPER(city); END;

Atnafu

from datetime import datetime current_day = datetime.now().strftime('%A') if current_day == 'Sunday': # Run the final query spark.sql("SELECT ... FROM ... WHERE ...") else: # Handle other scenarios or skip the final query pass