Certified Data Engineer Associate Exam QuestionsBrowse all questions from this exam

Certified Data Engineer Associate 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?

Show Answer
Correct Answer: AE

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

17 comments
Sign in to comment
FlexronOption: A
Mar 31, 2023

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

XiltroXOption: A
Apr 1, 2023

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
May 17, 2023

Both A and D use RETURN CASE

HuroyeOption: A
Nov 15, 2023

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....>

DavidRouOption: A
Oct 9, 2023

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

agAshishOption: D
Feb 1, 2024

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

AtnafuOption: A
Jul 7, 2023

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
Jul 7, 2023

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

akk_1289Option: A
Jul 19, 2023

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

d_b47Option: A
Sep 25, 2023

no UDF only FUNCTION needed.

KalavathiPOption: A
Sep 26, 2023

A is correct

AtanuChat
Sep 28, 2023

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

VijayKulaOption: A
Oct 9, 2023

Correct is A

VijayKulaOption: A
Oct 16, 2023

Create Function Return String

SerGreyOption: A
Jan 3, 2024

Correct answer is A

isamrat28Option: A
Feb 10, 2024

Correct Answer is A

a_51Option: A
Mar 16, 2024

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

benni_aleOption: A
Apr 27, 2024

A is correct

3fbc31bOption: A
Jul 8, 2024

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