I'm currently trying to refactor some SQL logic in Snowflake to improve readability and reduce repeated code by using UDF's.
Here is the UDF I'm trying to create:
create or replace function myfunc(var1 varchar, var2 varchar)
returns table (result int)
as
$$
select var1 from table1
where var2 = 1
$$;
select * from table(myfunc(column1, column2));
I want var1
and var2
to be two column names in table1
but not sure how to do that in SQL/Snowflake UDF.