quollio-core 0.6.4__py3-none-any.whl → 0.6.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quollio_core/__init__.py +1 -1
- quollio_core/dbt_projects/snowflake/macros/materialization/divided_view.sql +52 -36
- {quollio_core-0.6.4.dist-info → quollio_core-0.6.5.dist-info}/METADATA +1 -1
- {quollio_core-0.6.4.dist-info → quollio_core-0.6.5.dist-info}/RECORD +6 -6
- {quollio_core-0.6.4.dist-info → quollio_core-0.6.5.dist-info}/WHEEL +0 -0
- {quollio_core-0.6.4.dist-info → quollio_core-0.6.5.dist-info}/licenses/LICENSE +0 -0
quollio_core/__init__.py
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
{%- set identifier = model['alias'] %}
|
3
3
|
{%- set target_relations = [] %}
|
4
4
|
{%- set grant_config = config.get('grants') %}
|
5
|
+
{%- set max_columns_per_view = config.get('max_columns_per_view', 100) %}
|
5
6
|
|
6
7
|
{{ run_hooks(pre_hooks, inside_transaction=False) }}
|
7
|
-
--
|
8
|
+
-- BEGIN happens here:
|
8
9
|
{{ run_hooks(pre_hooks, inside_transaction=True) }}
|
9
10
|
|
10
11
|
-- fetch target_tables
|
@@ -41,45 +42,60 @@
|
|
41
42
|
|
42
43
|
-- create view for each table
|
43
44
|
{%- for stats_target_table in stats_target_tables -%}
|
44
|
-
|
45
|
-
{%- set
|
46
|
-
{
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
45
|
+
{%- set columns_json = fromjson(stats_target_table[3]) %}
|
46
|
+
{%- set column_list = columns_json.keys() | list %}
|
47
|
+
{%- set chunk_count = ((column_list | length) / max_columns_per_view) | round(0, 'ceil') | int %}
|
48
|
+
|
49
|
+
{%- for chunk_index in range(chunk_count) %}
|
50
|
+
{%- set start_idx = chunk_index * max_columns_per_view %}
|
51
|
+
{%- set end_idx = start_idx + max_columns_per_view %}
|
52
|
+
{%- set chunk_columns = column_list[start_idx:end_idx] %}
|
53
|
+
|
54
|
+
-- build sql for column value aggregation.
|
55
|
+
{%- set sql_for_column_stats %}
|
56
|
+
{%- for col_name in chunk_columns -%}
|
57
|
+
{%- set attr = columns_json[col_name] %}
|
58
|
+
{%- if not loop.first %}UNION{% endif %}
|
59
|
+
SELECT
|
60
|
+
DISTINCT
|
61
|
+
'{{stats_target_table[0]}}' as db_name
|
62
|
+
, '{{stats_target_table[1]}}' as schema_name
|
63
|
+
, '{{stats_target_table[2]}}' as table_name
|
64
|
+
, '{{col_name}}' as column_name
|
65
|
+
, {% if attr["IS_CALCULABLE"] == True %}CAST(MAX("{{col_name}}") AS STRING){% else %}NULL{% endif %} AS max_value
|
66
|
+
, {% if attr["IS_CALCULABLE"] == True %}CAST(MIN("{{col_name}}") AS STRING){% else %}NULL{% endif %} AS min_value
|
67
|
+
, COUNT_IF("{{col_name}}" IS NULL) AS null_count
|
68
|
+
, {% if attr["CAN_APPROX_COUNT"] == True %}APPROX_COUNT_DISTINCT("{{col_name}}"){% else %}NULL{% endif %} AS cardinality
|
69
|
+
, {% if attr["IS_CALCULABLE"] == True %}AVG("{{col_name}}"){% else %}NULL{% endif %} AS avg_value
|
70
|
+
, {% if attr["IS_CALCULABLE"] == True %}MEDIAN("{{col_name}}"){% else %}NULL{% endif %} AS median_value
|
71
|
+
, {% if attr["IS_CALCULABLE"] == True %}APPROX_TOP_K("{{col_name}}")[0][0]{% else %}NULL{% endif %} AS mode_value
|
72
|
+
, {% if attr["IS_CALCULABLE"] == True %}STDDEV("{{col_name}}"){% else %}NULL{% endif %} AS stddev_value
|
73
|
+
FROM "{{stats_target_table[0]}}"."{{stats_target_table[1]}}"."{{stats_target_table[2]}}" {{ var("sample_method") }}
|
74
|
+
{% endfor -%}
|
75
|
+
{%- endset %}
|
66
76
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
-- create a view with a index as suffix and chunk indicator
|
78
|
+
{%- set chunk_suffix = "" if chunk_count == 1 else "_PART" ~ (chunk_index + 1) %}
|
79
|
+
{%- set stats_view_identifier = "\"%s_%s_%s_%s%s\"" | format(model['name'], stats_target_table[0], stats_target_table[1], stats_target_table[2], chunk_suffix) | upper %}
|
80
|
+
{%- set schema_name = "\"%s\""|format(schema) %}
|
81
|
+
{%- set db_name = "\"%s\""|format(database) %}
|
82
|
+
{%- set target_relation = api.Relation.create(identifier=stats_view_identifier, schema=schema_name, database=db_name, type='view') %}
|
83
|
+
|
84
|
+
{{ log("Creating view " ~ stats_view_identifier ~ " with " ~ chunk_columns | length ~ " columns (chunk " ~ (chunk_index + 1) ~ " of " ~ chunk_count ~ ")", info=True) }}
|
85
|
+
|
86
|
+
{% call statement("main") %}
|
87
|
+
{{ get_create_view_as_sql(target_relation, sql_for_column_stats) }}
|
88
|
+
{% endcall %}
|
89
|
+
|
90
|
+
{%- set full_refresh_mode = (should_full_refresh()) -%}
|
91
|
+
{%- set should_revoke = should_revoke(target_relation, full_refresh_mode) %}
|
92
|
+
{%- do apply_grants(target_relation, grant_config, should_revoke) %}
|
93
|
+
{%- set target_relations = target_relations.append(target_relation) %}
|
94
|
+
{%- endfor %}
|
79
95
|
{%- endfor -%}
|
80
96
|
|
81
97
|
{{ run_hooks(post_hooks, inside_transaction=True) }}
|
82
|
-
--
|
98
|
+
-- COMMIT happens here:
|
83
99
|
{{ adapter.commit() }}
|
84
100
|
{{ run_hooks(post_hooks, inside_transaction=False) }}
|
85
101
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
quollio_core/__init__.py,sha256=
|
1
|
+
quollio_core/__init__.py,sha256=koimld9v7KxDLohX-mmvAh-Rd5GBygo2-_CqKN_L5lE,83
|
2
2
|
quollio_core/bigquery.py,sha256=6Oq4DVGpa3X21Es_nbrsb8pK3vaxwb9Egnvq3huo95k,5894
|
3
3
|
quollio_core/bricks.py,sha256=8h3kbI2b6lGH2s-56jE_Q5-R5-nIsQYMfvtRrkFOzoU,10784
|
4
4
|
quollio_core/redshift.py,sha256=KcdljY95xYf9JYrsaMOBoP_XxQQ8wFVE5ue_XEMVSFc,11504
|
@@ -47,7 +47,7 @@ quollio_core/dbt_projects/snowflake/packages_hub.yml,sha256=p9Bl2C44gdC6iYTUkz_1
|
|
47
47
|
quollio_core/dbt_projects/snowflake/packages_local.yml,sha256=ryyJSXv83gYFu48xmzG5Z1l746jGCUBE6hs7pUNwuXE,43
|
48
48
|
quollio_core/dbt_projects/snowflake/analyses/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
49
|
quollio_core/dbt_projects/snowflake/macros/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
|
-
quollio_core/dbt_projects/snowflake/macros/materialization/divided_view.sql,sha256=
|
50
|
+
quollio_core/dbt_projects/snowflake/macros/materialization/divided_view.sql,sha256=WjN_baGb_FuDX831rR5G7Payw5t91VaoQobEkTJR3jQ,4880
|
51
51
|
quollio_core/dbt_projects/snowflake/macros/materialization/get_imported_databases.sql,sha256=WAFl9CyM-G07O7vZD2MkA1hncpjV_gSMGc2V8nRJRPk,1435
|
52
52
|
quollio_core/dbt_projects/snowflake/models/quollio_lineage_column_level.sql,sha256=Zhj0EXF1K8S-OkFxz3IBHe2olXktYrvly0LwZBOAUXw,5333
|
53
53
|
quollio_core/dbt_projects/snowflake/models/quollio_lineage_column_level.yml,sha256=a2uNIAh-xw51eu-GmHVuAnGnTbwK7h8-DjDeQtK3KaQ,711
|
@@ -90,7 +90,7 @@ quollio_core/repository/redshift.py,sha256=p2ouEuYcDCjx1oBhc6H1ekQsvEqHGd3bFu3PW
|
|
90
90
|
quollio_core/repository/snowflake.py,sha256=yCYXrYf4I5GL_ITNTXoggj0xNbQsdwxPSmsVvZYwUVU,3869
|
91
91
|
quollio_core/repository/ssm.py,sha256=xpm1FzbBnIsBptuYPUNnPgkKU2AH3XxI-ZL0bEetvW0,2182
|
92
92
|
quollio_core/repository/teradata.py,sha256=1AExxRBTswpSyF4OVyAUkoiZ0yVRfqt4T99FdllkTEI,3763
|
93
|
-
quollio_core-0.6.
|
94
|
-
quollio_core-0.6.
|
95
|
-
quollio_core-0.6.
|
96
|
-
quollio_core-0.6.
|
93
|
+
quollio_core-0.6.5.dist-info/licenses/LICENSE,sha256=V8j_M8nAz8PvAOZQocyRDX7keai8UJ9skgmnwqETmdY,34520
|
94
|
+
quollio_core-0.6.5.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
95
|
+
quollio_core-0.6.5.dist-info/METADATA,sha256=hYXyuls1a0DulGYU33B98YwO3Y9yBg2KOhXIIxOGrVk,7023
|
96
|
+
quollio_core-0.6.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|