小编use*_*172的帖子

是否可以在 Snowflake Snowpark 中的 Python UDF 中编写 SQL 查询?

我正在尝试在雪花中创建一个新的 UDF 函数。在此 UDF 中,我需要编写一个 SQL 查询来返回表列表,然后我需要围绕它执行一些 Python 代码,如下例所示:

create or replace function SnowparkPrivateSchema()
returns string
language python
runtime_version=3.8
handler='SnowparkPrivateSchema'
as $$
def SnowparkPrivateSchema(self, symbol, quantity, price):
   get_tables = '''select table_name from  INFORMATION_SCHEMA.TABLES'''
   for table in get_tables:
      '''create or replace table clone_user.{table} clone {table}'''

$$;
Run Code Online (Sandbox Code Playgroud)

python sql user-defined-functions snowflake-cloud-data-platform

3
推荐指数
1
解决办法
4960
查看次数