【发布时间】:2023-01-20 17:18:49
【问题描述】:
我需要一些帮助来应用 python UDF 在我的 dbt 模型上运行。 我成功地在 snowflake (DWH) 中创建了一个 python 函数并针对一个表运行它。这似乎按预期工作,但在 dbt 上实现它似乎很困难。一些建议/帮助/指导会让我开心。
这是我在雪花上创建的 python UDF
create or replace function "077"."Unity".sha3_512(str varchar)
returns varchar
language python
runtime_version = '3.8'
handler = 'hash'
as
$$
import hashlib
def hash(str):
# create a sha3 hash object
hash_sha3_512 = hashlib.new("sha3_512", str.encode())
return hash_sha3_512.hexdigest()
$$
;
目标是在 dbt 中创建 python 函数并将其应用于下面的模型
{{ config(materialized = 'view') }}
WITH SEC AS(
SELECT
A."AccountID" AS AccountID,
A."AccountName" AS AccountName ,
A."Password" AS Passwords,
apply function here (A."Password") As SHash
FROM {{ ref('Green', 'Account') }} A
)
----------------VIEW RECORD------------------------------
SELECT *
FROM SEC
有没有办法做到这一点。谢谢
【问题讨论】:
标签: python snowflake-cloud-data-platform dbt