Skip to content

Commit db33b99

Browse files
Update changelog for v0.3.8.3 and enhance function ownership SQL macro to fix argument signature handling
1 parent 9648497 commit db33b99

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Data Engineers Snowflake DataOps Utils Project Changelog
2+
This file contains the changelog for the Data Engineers Snowflake DataOps Utils project, detailing updates, fixes, and enhancements made to the project over time.
23

3-
## v0.3.8.2 2025-08-15 - Stored Procedure Grants Fix
4+
## v0.3.8.3 2025-07-30 - Grant Fixes
5+
6+
* updated macro `get_grant_functions_ownership_sql` to fix issue with parameterless function signature not being returned correctly
7+
* added additional logging to `grant_object` macro to ensure that the correct parameters are being passed
8+
9+
## v0.3.8.2 2025-07-15 - Grant Fixes
410

511
* added additional logging to `grant_object` macro to ensure that the correct parameters are being passed
612

macros/grants/grant_object.sql

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
{% set revoke_statements = [] %}
44
{% set grant_statements = [] %}
55
{% set existing_grants = [] %}
6+
{% set execute_statements = [] %}
67

78
{% for object in objects %}
8-
{% do log("processing " ~ grant_types ~ " for " ~ object ~ " for " ~ grant_roles, info=True) %}
9+
{% do log("====> Processing " ~ object_type ~ " for " ~ object, info=True) %}
910
{% set query %}
1011
show grants on {{ object_type }} {{ target.database }}.{{ object }};
1112
{% endset %}
@@ -40,18 +41,20 @@
4041
{%endif%}
4142
{%endfor%}
4243
{% for stm in revoke_statements %}
43-
{% set grant_query %}
44-
revoke {{ stm.privilege }} on {{ object_type }} {{ target.database }}.{{ stm.object }} from role {{ stm.role }};
45-
{% endset %}
46-
{% do log(grant_query, info=True) %}
47-
{% set grant = run_query(grant_query) %}
44+
{{ execute_statements.append("revoke " ~ stm.privilege ~ " on " ~ object_type ~ " " ~ target.database ~ "." ~ stm.object ~ " from role " ~ stm.role ~ ";") }}
4845
{% endfor %}
4946
{% for stm in grant_statements %}
50-
{% set grant_query %}
51-
grant {{ stm.privilege }} on {{ object_type }} {{ target.database }}.{{ stm.object }} to role {{ stm.role }};
52-
{% endset %}
53-
{% do log(grant_query, info=True) %}
54-
{% set grant = run_query(grant_query) %}
47+
{{ execute_statements.append("grant " ~ stm.privilege ~ " on " ~ object_type ~ " " ~ target.database ~ "." ~ stm.object ~ " to role " ~ stm.role ~ ";") }}
5548
{% endfor %}
49+
{% if execute_statements | length > 0 %}
50+
{% do log("Executing privilege grants and revokes for " ~ object_type ~"s...", info=True) %}
51+
{% for statement in execute_statements %}
52+
{% do log(statement, info=True) %}
53+
{% set grant = run_query(statement) %}
54+
{% endfor %}
55+
{% do log("Privilege grants and revokes executed successfully for " ~ object_type ~ "s.", info=True) %}
56+
{% else %}
57+
{% do log("No privilege grants or revokes to execute for " ~ object_type ~ "s.", info=True) %}
58+
{% endif %}
5659
{% endif %}
5760
{% endmacro %}

macros/grants/ownerships/get_grant_functions_ownership_sql.sql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
function_catalog,
55
function_schema as schema_name,
66
function_name,
7-
listagg(trim(split_part(arg, ' ', -1)), ',') as argument_signature
7+
regexp_replace(
8+
listagg(trim(split_part(arg, ' ', -1)), ',') within group (order by arg),
9+
'^,',
10+
''
11+
) as argument_signature
812
from (
913
select
1014
function_catalog,
@@ -22,7 +26,6 @@
2226
and function_schema in ({{ schema_list }})
2327
),
2428
lateral flatten(input => args) as f
25-
where trim(f.value) <> ''
2629
)
2730
group by function_catalog, function_schema, function_name;
2831
{% endset %}

0 commit comments

Comments
 (0)