How to write java user defined function in Snowflake
How to use strict property in Snowflake UDFs
User Defined Functions in Snowflake Video
You can watch the complete hands on video tutorial
Step-5: Java & SQL Construct
class MyJavaUDF {
private double x;
// Constructor
public MyJavaUDF() {
x = Math.random();
}
// Handler
public double myHandler() {
return x;
}
public static void main(String [] args){
MyJavaUDF mc = new MyJavaUDF();
System.out.println(mc.myHandler());
}
}
use role sysadmin;
use database ttips;
use schema udfs;
use warehouse compute_wh;
-- lets list if my jar is available or not
list @~;
create or replace function my_java_udf()
returns double
language java
imports = ('@~/java-udf/MyUDF.jar')
handler = 'MyJavaUDF.myHandler';
desc function my_java_udf();
select my_java_udf(),my_java_udf(),my_java_udf();
select my_java_udf()
union all
select my_java_udf();
show functions like 'MY_JAVA%';
- Part-02 User Defined Function in Snowflake SQLs
- Part-02 JavaScript & SQL User Defined Function in Snowflake SQLs
- Part-03 Strict Property User Defined Function in Snowflake SQLs
- Part-04 Not Null Return User Defined Function in Snowflake SQLs
- Part-05 Secure User Defined Function in Snowflake SQLs
- Part-06 Inbuilt Vs. User Defined Function in Snowflake SQLs
- Part-07 Table User Defined Function in Snowflake SQLs
- Part-08 Method Overloading SQL Script
- Part-09 Java User Defined Function SQL & Java Code