0% found this document useful (0 votes)
88 views1 page

Calling Functions and Stored Procedures in Snowpark Java - Snowflake Documentation

The document discusses how to call functions and stored procedures in Snowpark Java. It explains how to call system-defined SQL functions using the Functions class and how to call user-defined functions and stored procedures. It provides examples of calling the upper and radians functions and discusses passing column values to functions.

Uploaded by

demorepo99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views1 page

Calling Functions and Stored Procedures in Snowpark Java - Snowflake Documentation

The document discusses how to call functions and stored procedures in Snowpark Java. It explains how to call system-defined SQL functions using the Functions class and how to call user-defined functions and stored procedures. It provides examples of calling the upper and radians functions and discusses passing column values to functions.

Uploaded by

demorepo99
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

4/29/24, 3:05 PM Calling functions and stored procedures in Snowpark Java | Snowflake Documentation

Developer Snowpark API Java Calling Functions and Stored Procedures


Calling functions and stored procedures in
Snowpark Java
To process data in a DataFrame, you can call system-defined SQL functions, user-
defined functions, and stored procedures. This topic explains how to call these in
Snowpark.
Calling system-defined functions
If you need to call system-defined SQL functions, use the equivalent static methods
in the Functions class.
The following example calls the upper static method in the Functions class (the
equivalent of the system-defined UPPER function) to return the values in the name
column with the letters in uppercase:
DataFrame df = session.table("sample_product_data");
df.select(Functions.upper(Functions.col("name"))).show();

If a system-defined SQL function is not available in the Functions class, you can
use the Functions.callUDF static method to call the system-defined function.
For callUDF , pass the name of the system-defined function as the first argument.
If you need to pass the values of columns to the system-defined function, define
and pass Column objects as additional arguments to the callUDF method.
The following example calls the system-defined function RADIANS, passing in the
value from the column degrees :
// Call the system-defined function RADIANS() on degrees.
DataFrame dfDegrees = session.range(0, 360, 45).rename("degrees", Fun
dfDegrees.select(Functions.col("degrees"), Functions.callUDF("radians

The callUDF method returns a Column , which you can pass to the DataFrame
transformation methods (e.g. filter, select, etc.).
Calling scalar user-defined functions (UDFs)
https://docs.snowflake.com/en/developer-guide/snowpark/java/calling-functions 1/1

You might also like