nerdexam
DatabricksDatabricks

CERTIFIED-DATA-ANALYST-ASSOCIATE · Question #11

CERTIFIED-DATA-ANALYST-ASSOCIATE Question #11: Real Exam Question with Answer & Explanation

The correct answer is E: SELECT price(customer_spend, customer_units) AS customer_price FROM customer_summary. Option E correctly invokes the UDF using standard SQL function-call syntax: price(customer_spend, customer_units) passes the two required DOUBLE arguments, AS customer_price aliases the result, and FROM customer_summary specifies the source table - matching exactly how the functi

Question

A data analyst has created a user-defined function using the following line of code: CREATE FUNCTION price(spend DOUBLE, units DOUBLE) RETURNS DOUBLE RETURN 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?

Options

  • ASELECT PRICE customer_spend, customer_units AS customer_price FROM customer_summary
  • BSELECT price FROM customer_summary
  • CSELECT function(price(customer_spend, customer_units)) AS customer_price FROM
  • DSELECT double(price(customer_spend, customer_units)) AS customer_price FROM
  • ESELECT price(customer_spend, customer_units) AS customer_price FROM customer_summary

Explanation

Option E correctly invokes the UDF using standard SQL function-call syntax: price(customer_spend, customer_units) passes the two required DOUBLE arguments, AS customer_price aliases the result, and FROM customer_summary specifies the source table - matching exactly how the function was defined.

Why the distractors fail:

  • A treats PRICE as a column name rather than calling it as a function, and the syntax PRICE customer_spend, customer_units is malformed.
  • B references price as if it were a plain column in the table, with no arguments - UDFs require argument lists.
  • C wraps the call in function(...), which is not valid SQL syntax; there is no function() wrapper in SQL.
  • D wraps the call in double(...), which is not a valid SQL function; DOUBLE is a data type, not a callable wrapper.

Memory tip: Call a UDF exactly like a built-in SQL function - functionName(arg1, arg2) - no wrappers, no type names, just the function name followed by its arguments in parentheses. If it was defined with parameters, you must supply them.

Community Discussion

No community discussion yet for this question.

Full CERTIFIED-DATA-ANALYST-ASSOCIATE PracticeBrowse All CERTIFIED-DATA-ANALYST-ASSOCIATE Questions