{"id":1877,"date":"2022-12-12T12:14:49","date_gmt":"2022-12-12T03:14:49","guid":{"rendered":"https:\/\/www.kwonline.org\/memo2\/?p=1877"},"modified":"2022-12-12T12:16:25","modified_gmt":"2022-12-12T03:16:25","slug":"dbt-needs-ownership-when-create-or-replace-function-on-snowflake","status":"publish","type":"post","link":"https:\/\/www.kwonline.org\/memo2\/2022\/12\/12\/dbt-needs-ownership-when-create-or-replace-function-on-snowflake\/","title":{"rendered":"dbt \u3067 snowflake function \u3092\u5236\u5fa1\u3059\u308b\u306b\u306f ownership \u304c\u5fc5\u8981"},"content":{"rendered":"<p>&nbsp;<br \/>\ndbt \u3067 Snowflake \u306b UDF \u3092\u4f5c\u308d\u3046\u3068\u3057\u305f\u3089 Insufficient privileges to operate on function \u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u6012\u3089\u308c\u305f\u306e\u3067\u30e1\u30e2\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306a macro \u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u3068\u3057\u3066<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n{% macro create_replace_title() %}\r\nCREATE OR REPLACE FUNCTION string_reverse_nulls(S string)\r\n    RETURNS string\r\n    LANGUAGE JAVASCRIPT\r\n    AS '\r\n    if (S === undefined) {\r\n        return &quot;string was null&quot;;\r\n    } else {\r\n        return undefined;\r\n    }';\r\n{% endmacro %}\r\n<\/pre>\n<p>\u3053\u308c\u3092 dbt run \u306e pre_hook \u3067\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nDatabase Error in model stg_hoge (models\/staging\/stg_hoge.sql)\r\n   003001 (42501): SQL access control error:\r\n   Insufficient privileges to operate on function 'string_reverse_nulls'\r\n<\/pre>\n<p>dbt \u30e6\u30fc\u30b6\u30fc\u306b\u306f GRANT ALL \u3057\u3066\u308b\u306e\u306b\uff1f\u3068\u601d\u3063\u305f\u3089 ALL \u3058\u3083\u8db3\u308a\u306a\u3044\u3002<\/p>\n<p>\u5bfe\u7b56\u306f\u3001dbt \u30e6\u30fc\u30b6\u30fc\u306e\u30ed\u30fc\u30eb\u306b <strong>OWNERSHIP<\/strong> \u3092\u4ed8\u4e0e\u3059\u308c\u3070OK.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\nGRANT ownership ON all functions in database staging to role transformer REVOKE CURRENT GRANTS;\r\nGRANT ownership ON future functions in database staging to role transformer REVOKE CURRENT GRANTS;\r\n<\/pre>\n<p>ALL \u3060\u3068\u6240\u6709\u6a29\u304c\u4ed8\u4e0e\u3055\u308c\u306a\u3044\u306e\u306d\u3002<br \/>\n&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; dbt \u3067 Snowflake \u306b UDF \u3092\u4f5c\u308d\u3046\u3068\u3057\u305f\u3089 Insufficient privileges to operate on function \u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u51fa\u3066\u6012\u3089\u308c\u305f\u306e\u3067\u30e1\u30e2\u3002 \u3053\u306e\u3088\u3046\u306a  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,27,20],"tags":[],"class_list":["post-1877","post","type-post","status-publish","format-standard","hentry","category-dbt","category-snowflakedb","category-sql"],"_links":{"self":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/1877","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/comments?post=1877"}],"version-history":[{"count":6,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/1877\/revisions"}],"predecessor-version":[{"id":1883,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/posts\/1877\/revisions\/1883"}],"wp:attachment":[{"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/media?parent=1877"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/categories?post=1877"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kwonline.org\/memo2\/wp-json\/wp\/v2\/tags?post=1877"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}