【发布时间】:2020-02-12 16:32:50
【问题描述】:
我在这样定义的自定义函数中使用了相对昂贵的计算:
CREATE TEMP FUNCTION HMAC256(message STRING, secret STRING)
RETURNS STRING
LANGUAGE js
OPTIONS (
-- copy this Forge library file to Storage:
-- https://cdn.jsdelivr.net/npm/node-forge@0.7.0/dist/forge.min.js
-- @see https://github.com/digitalbazaar/forge
library=["gs://.../forge.min.js"]
)
AS
"""
var hmac = forge.hmac.create();
hmac.start('sha256', secret);
hmac.update(message);
return hmac.digest().toHex();
""";
SELECT HMAC256("test", "111");
-- Row f0_
-- 1 f8320c4eded4b06e99c1a884a25c80b2c88860e13b64df1eb6f0d3191023482b
与例如应用LOWER 函数相比,这会更昂贵吗?
HMAC256 在我的数据集上花费了 4 分钟,而在 LOWER 上花费了 14 秒,我在字节计费详细信息中看不到任何不同。
如果价格相同,那就太棒了。我有一种感觉,我错过了什么。
【问题讨论】:
-
恭喜你运行了 js HMAC。它是否匹配 R 的 SHA256() 函数?
-
是的,它与我的 R/python hmac 匹配
标签: google-bigquery cost-management