I’ve got some complex business logic I’m trying to...
# integration-snowflake
s
I’ve got some complex business logic I’m trying to implement in a Snowflake Python UDTF. It needs to run as a UDF and not in a full blown dagster project. However, I think the ops/graph abstraction would be very helpful in clarifying this logic. I’m curious whether anyone has anyone tried to implement these methods in a Python UDF?
j
hey @Sterling Paramore I’m not all too familiar with UDFs, but I imagine you could have ops for creating the different UDFs or calling them (not sure which you have in mind), and then connect them together in a graph based on the required dependencies. The Snowflake Resource should be useful to you for running the different sql queries pulling from the snowflake docs, i think you should be able to do something like this
Copy code
@op 
def create_addone_udf(snowflake: SnowflakeResource):
   sql = """CREATE OR REPLACE FUNCTION addone(i int)
RETURNS INT
LANGUAGE PYTHON
RUNTIME_VERSION = '3.8'
HANDLER = 'addone_py'
as
$$
def addone_py(i):
  return i+1
$$;
"""

   with snowflake.get_connection() as conn:
     conn.cursor.execute(sql)
s
I was thinking the opposite. I want the UDF to run dagster, so decorate the
addone_py
with
@op
.
j
ohhh i see. i don’t see an immediate reason it shouldn’t work, but i dont know what the limitations are on the snowflake compute environment. probably worth testing out, and maybe some other community members will have experience with this!