Databricks Certified Data Analyst Associate Exam - Topic 5 Question 40 Discussion
A data analyst has created a user-defined function using the following line of code:CREATE FUNCTION price(spend DOUBLE, units DOUBLE)RETURNS DOUBLERETURN spend / units;Which of the following code blocks can be used to apply this function to the customer_spend and customer_units columns of the table customer_summary to create column customer_price?
E) SELECT price(customer_spend, customer_units) AS customer_price FROM customer_summary
A user-defined function (UDF) is a function defined by a user, allowing custom logic to be reused in the user environment1.To apply a UDF to a table, the syntax isSELECT udf_name(column_name) AS alias FROM table_name2. Therefore, option E is the correct way to use the UDFpriceto create a new columncustomer_pricebased on the existing columnscustomer_spendandcustomer_unitsfrom the tablecustomer_summary.Reference:
What are user-defined functions (UDFs)?
User-defined scalar functions - SQL
V
A) SELECT PRICE customer_spend, customer_units AS customer_price FROM customer_summary
B) SELECT price FROM customer_summary
C) SELECT function(price(customer_spend, customer_units)) AS customer_price FROM customer_summary
D) SELECT double(price(customer_spend, customer_units)) AS customer_price FROM customer_summary
Corinne
7 months agoBrandon
7 months agoDottie
7 months agoAlesia
7 months agoEnola
7 months agoAlica
8 months agoVirgina
8 months agoMarsha
8 months agoEmerson
8 months agoDaniel
8 months agoRosamond
9 months agoMalcolm
9 months agoLaurel
9 months agoLenna
9 months agoGlenn
11 months agoKaty
10 months agoLelia
10 months agoRhea
12 months agoFatima
12 months agoJettie
12 months agoAileen
12 months agoJacquelyne
11 months agoQueen
11 months agoTeri
12 months agoEleni
11 months agoThaddeus
11 months agoVi
12 months ago