Skip to content

Commit

Permalink
Merge pull request #9 from robscriva/feature/log-time-format
Browse files Browse the repository at this point in the history
Change datetime call and format for logging
  • Loading branch information
entechlog authored Aug 25, 2021
2 parents f1099a1 + 9a0d0f6 commit 935c7f2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions macros/snow-mask/apply_masking_policy_list_for_models.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

{% for masking_policy_in_db in masking_policy_list['MASKING_POLICY'] %}
{% if database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper == masking_policy_in_db %}
{{ log(modules.datetime.time() ~ " | " ~ operation_type ~ "ing masking policy to model : " ~ database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper ~ " on " ~ database ~ '.' ~ schema ~ '.' ~ alias ~ '.' ~ column, info=True) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | " ~ operation_type ~ "ing masking policy to model : " ~ database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper ~ " on " ~ database ~ '.' ~ schema ~ '.' ~ alias ~ '.' ~ column, info=True) }}
{% set query %}
alter {{materialization}} {{database}}.{{schema}}.{{alias}} modify column {{column}} set masking policy {{database}}.{{schema}}.{{masking_policy_name}};
{% endset %}
Expand Down Expand Up @@ -58,7 +58,7 @@
{% set masking_policy_name = meta_tuple[1] %}

{% if masking_policy_name is not none %}
{{ log(modules.datetime.time() ~ " | " ~ operation_type ~ "ing masking policy to model : " ~ database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper ~ " on " ~ database ~ '.' ~ schema ~ '.' ~ alias ~ '.' ~ column, info=True) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | " ~ operation_type ~ "ing masking policy to model : " ~ database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper ~ " on " ~ database ~ '.' ~ schema ~ '.' ~ alias ~ '.' ~ column, info=True) }}
{% set query %}
alter {{materialization}} {{database}}.{{schema}}.{{alias}} modify column {{column}} unset masking policy
{% endset %}
Expand Down
2 changes: 1 addition & 1 deletion macros/snow-mask/apply_masking_policy_list_for_sources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

{% for masking_policy_in_db in masking_policy_list['MASKING_POLICY'] %}
{% if database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper == masking_policy_in_db %}
{{ log(modules.datetime.time() ~ " | " ~ operation_type ~ "ing masking policy to source : " ~ database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper ~ " on " ~ database ~ '.' ~ schema ~ '.' ~ name ~ '.' ~ column, info=True) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | " ~ operation_type ~ "ing masking policy to source : " ~ database|upper ~ '.' ~ schema|upper ~ '.' ~ masking_policy_name|upper ~ " on " ~ database ~ '.' ~ schema ~ '.' ~ name ~ '.' ~ column, info=True) }}
{% set query %}
{% if operation_type == "apply" %}
alter {{materialization}} {{database}}.{{schema}}.{{name}} modify column {{column}} set masking policy {{database}}.{{schema}}.{{masking_policy_name}}
Expand Down
2 changes: 1 addition & 1 deletion macros/snow-mask/create_masking_policy.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{% set current_database = masking_policy[0] | string %}
{% set current_schema = masking_policy[1] | string %}
{% set current_policy_name = masking_policy[2] | string %}
{{ log(modules.datetime.time() ~ " | creating masking policy : " ~ current_database|upper ~ '.' ~ current_schema|upper ~ '.' ~ current_policy_name|upper , info=True) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | creating masking policy : " ~ current_database|upper ~ '.' ~ current_schema|upper ~ '.' ~ current_policy_name|upper , info=True) }}
{% set call_masking_policy_macro = context["create_masking_policy_" | string ~ current_policy_name | string] %}
{{ run_query(call_masking_policy_macro(current_database, current_schema)) }}
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions macros/snow-mask/get_masking_policy_list_for_models.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% for node in graph.nodes.values() -%}

{{ log(modules.datetime.time() ~ " | macro - now processing : " ~ node.unique_id | string , info=False) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | macro - now processing : " ~ node.unique_id | string , info=False) }}

{% set node_database = node.database | string %}
{% set node_schema = node.schema | string %}
Expand All @@ -14,7 +14,7 @@
{% set meta_columns = dbt_snow_mask.get_meta_objects(node_unique_id,meta_key,node_resource_type) %}

{%- for meta_tuple in meta_columns if meta_columns | length > 0 %}
{{ log(modules.datetime.time() ~ " | macro - meta_columns : " ~ node_unique_id ~ " has " ~ meta_columns | string ~ " masking tags set", info=False) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | macro - meta_columns : " ~ node_unique_id ~ " has " ~ meta_columns | string ~ " masking tags set", info=False) }}

{% set column = meta_tuple[0] %}
{% set masking_policy_name = meta_tuple[1] %}
Expand Down
4 changes: 2 additions & 2 deletions macros/snow-mask/get_masking_policy_list_for_sources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% for node in graph.sources.values() -%}

{{ log(modules.datetime.time() ~ " | macro - now processing : " ~ node.unique_id | string , info=False) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | macro - now processing : " ~ node.unique_id | string , info=False) }}

{% set node_database = node.database | string %}
{% set node_schema = node.schema | string %}
Expand All @@ -14,7 +14,7 @@
{% set meta_columns = dbt_snow_mask.get_meta_objects(node_unique_id,meta_key,node_resource_type) %}

{%- for meta_tuple in meta_columns if meta_columns | length > 0 %}
{{ log(modules.datetime.time() ~ " | macro - meta_columns : " ~ node_unique_id ~ " has " ~ meta_columns | string ~ " masking tags set", info=False) }}
{{ log(modules.datetime.datetime.now().strftime("%H:%M:%S") ~ " | macro - meta_columns : " ~ node_unique_id ~ " has " ~ meta_columns | string ~ " masking tags set", info=False) }}

{% set column = meta_tuple[0] %}
{% set masking_policy_name = meta_tuple[1] %}
Expand Down

0 comments on commit 935c7f2

Please sign in to comment.