Writing and choosing between SQL, JavaScript, and Snowpark UDFs
User-Defined Functions (UDFs) let you extend SQL with custom scalar or tabular logic written in SQL, JavaScript, Python, Java, or Scala, returning either a single value or a set of rows. They are called inline within SQL statements like built-in functions and are ideal for encapsulating reusable business logic or complex computations.
1 · Learn the must-know
- UDFs can be scalar (return one value per call) or tabular/UDTFs (return a set of rows, used with LATERAL or in the FROM clause).
- Snowflake supports SQL, JavaScript, Python, Java, and Scala as UDF languages, each defined with CREATE FUNCTION and a LANGUAGE clause.
- UDFs can be created as SECURE to hide the function definition and logic from unauthorized users, at the cost of some query optimization visibility.
- Unlike stored procedures, UDFs cannot execute DDL/DML or control transactions—they are meant for computation, not side effects, and are used purely as expressions within SQL.
- Python, Java, and Scala UDFs run in a sandboxed environment and can reference external packages via PACKAGES clause or staged files via IMPORTS.
- UDFs can be overloaded (same name, different argument signatures) and support default values, but each overload is a distinct function object internally.
2 · Check your understanding
A Data Engineer maintains a UDF named CALC_MARGIN that embeds a proprietary formula. The function is granted to a share so partner accounts can call it in their own queries. Compliance requires that partner accounts be able to invoke the function but never see its SQL body through SHOW FUNCTIONS, GET_DDL, or the ACCOUNT_USAGE views.
Which change satisfies this requirement without breaking the partners' ability to invoke the function?
What you have tried across SnowPro Advanced Data Engineer's objectives, not a readiness score.
Data Movement28% of the exam*0 of 7 tried
Performance Optimization19% of the exam*0 of 3 tried
Storage and Data Protection14% of the exam*0 of 3 tried
Data Governance14% of the exam*0 of 2 tried
Data Transformation25% of the exam*0 of 7 tried
* Our estimate. Snowflake publishes no section weights.
3 · Keep going
Ready for more? Take a weighted mock or try free practice questions.