COF-C02 practice question 2 of 35

What kind of value does a User-Defined Function (UDF) return? (Select TWO).

Full set: 778 questions
Answer options
A: Dictionary
B: List
C: Object
D: Scalar Correct answer
E: Tabular Correct answer
Correct Answer:
D. Scalar; E. Tabular
Explanation

User-Defined Functions (UDFs) in Snowflake are categorized by the type of value they return. A UDF can return a single value, such as an integer, string, or variant; this is known as a scalar function. Alternatively, a UDF can return a set of rows, effectively behaving like a table in the FROM clause of a query; this is known as a tabular function, or User-Defined Table Function (UDTF). These are the two fundamental return types for UDFs.

Why Incorrect

A. Dictionary is a data structure in languages like Python. In Snowflake, this would be represented by the OBJECT data type, making 'Object' the more correct term.
B. List is a data structure in programming languages. The equivalent SQL data type in Snowflake is ARRAY, which is a type of scalar value.
C. An OBJECT is a specific data type that can be returned by a scalar UDF. 'Scalar' is the broader, correct category that encompasses OBJECT, INTEGER, VARCHAR, etc.

References

1. Snowflake Documentation. (n.d.). Introduction to User-Defined Functions. In Development. Retrieved from https://docs.snowflake.com/en/developer-guide/udf/udf-overview. "A user-defined function (UDF) returns either a single (scalar) value or a set of rows (tabular value)."

2. Snowflake Documentation. (n.d.). SQL UDFs. In Development. Retrieved from https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql. The documentation distinguishes between "Scalar UDFs (UDFs)" and "Tabular UDFs (UDTFs)".

Scroll to Top