QuestionQ26

VerifiedData Modeling with Databricks SQL

A data analyst created a user-defined function with the following code:

CREATE FUNCTION price(spend DOUBLE, units DOUBLE)  
  
RETURNS DOUBLE -  
RETURN spend / units;  

Which of the following code blocks can apply this function to the customer_spend and customer_units columns in the customer_summary table to create the customer_price column?

Explanation

A SQL scalar user-defined function is called using its name followed by parenthesized arguments. Passing customer_spend and customer_units to price produces the returned quotient for each row, and AS customer_price names that result column. Databricks documents the same pattern with SELECT area(c1, c2) AS area FROM t;.

Learn more

Community Discussion

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