|
| 1 | +{%- macro upload_dbt_groups(should_commit=false, metadata_hashes=none) -%} |
| 2 | + {% set relation = elementary.get_elementary_relation('dbt_groups') %} |
| 3 | + {% if execute and relation %} |
| 4 | + {% set groups = graph.groups.values() | selectattr('resource_type', '==', 'group') %} |
| 5 | + {% do elementary.upload_artifacts_to_table(relation, groups, elementary.flatten_group, should_commit=should_commit, metadata_hashes=metadata_hashes) %} |
| 6 | + {%- endif -%} |
| 7 | + {{- return('') -}} |
| 8 | +{%- endmacro -%} |
| 9 | + |
| 10 | +{% macro get_dbt_groups_empty_table_query() %} |
| 11 | + {% set columns = [ |
| 12 | + ('unique_id', 'string'), |
| 13 | + ('name', 'string'), |
| 14 | + ('owner_email', 'string'), |
| 15 | + ('owner_name', 'string'), |
| 16 | + ('generated_at', 'string'), |
| 17 | + ('metadata_hash', 'string'), |
| 18 | + ] %} |
| 19 | + |
| 20 | + {% set dbt_groups_empty_table_query = elementary.empty_table(columns) %} |
| 21 | + {{ return(dbt_groups_empty_table_query) }} |
| 22 | +{% endmacro %} |
| 23 | + |
| 24 | +{% macro flatten_group(node_dict) %} |
| 25 | + {% set owner_dict = elementary.safe_get_with_default(node_dict, 'owner', {}) %} |
| 26 | + |
| 27 | + {% set flatten_group_metadata_dict = { |
| 28 | + 'unique_id': node_dict.get('unique_id'), |
| 29 | + 'name': node_dict.get('name'), |
| 30 | + 'owner_email': owner_dict.get('email'), |
| 31 | + 'owner_name': owner_dict.get('name'), |
| 32 | + 'generated_at': elementary.datetime_now_utc_as_string(), |
| 33 | + } %} |
| 34 | + {% do flatten_group_metadata_dict.update({'metadata_hash': elementary.get_artifact_metadata_hash(flatten_group_metadata_dict)}) %} |
| 35 | + {{ return(flatten_group_metadata_dict) }} |
| 36 | +{% endmacro %} |
0 commit comments