Initial publish of dbt_f2dq (f2dq) package v0.12.1.

Clean package repo for Gitea installs via packages.yml git URL.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
M7XBeast
2026-10-11 17:37:40 +03:00
co-authored by Cursor
commit ff096b51b5
188 changed files with 5251 additions and 0 deletions
View File
@@ -0,0 +1,28 @@
{% macro create_test_source_tables() %}
{% set create_table %}
CREATE SCHEMA IF NOT EXISTS {{target.schema}};
DROP TABLE IF EXISTS {{target.schema}}.f2dq_source_test_table;
CREATE TABLE IF NOT EXISTS {{target.schema}}.f2dq_source_test_table (
number {{ f2dq.integer_type() }},
description {{ f2dq.string_type() }},
created_at {{ f2dq.timestamp_type() }}
);
INSERT INTO {{target.schema}}.f2dq_source_test_table (number, description, created_at) VALUES
(1, 'one', current_timestamp),
(2, 'two', current_timestamp),
(3, 'three', current_timestamp),
(4, 'four', current_timestamp),
(5, 'five', current_timestamp),
(6, 'six', current_timestamp),
(7, 'seven', current_timestamp),
(8, 'eight', current_timestamp),
(9, 'nine', current_timestamp),
(10, 'ten', current_timestamp
);
{% endset %}
{% do run_query(create_table) %}
{% endmacro %}
@@ -0,0 +1,48 @@
{% macro get_schemas_used(schema_name) %}
{% set schemas = [
schema_name,
schema_name + '_re',
schema_name + '_re_internal',
schema_name + '_raw',
schema_name + '_expected',
schema_name + '_dbt_test__audit',
schema_name + '_seeds'
] %}
{{ return (schemas) }}
{% endmacro %}
{% macro drop_all_schemas(schema_name) %}
{% set schemas_to_drop = get_schemas_used(schema_name) %}
{{ adapter.dispatch('drop_all_schemas')(schemas_to_drop) }}
{% endmacro %}
{% macro default__drop_all_schemas(schemas_to_drop) %}
{% for schema in schemas_to_drop %}
{% set relation = api.Relation.create(database=target.database, schema=schema) %}
{% do adapter.drop_schema(relation) %}
{% endfor %}
{% endmacro %}
{% macro redshift__drop_all_schemas(schemas_to_drop) %}
{#
dropping schemas with adapter.drop_schema doesn't seem to work with redshift
so we default to issuing DDL commands to redshift
#}
{% set drop_query %}
{% for schema in schemas_to_drop %}
drop schema if exists {{schema}} cascade;
{% endfor %}
{% endset %}
{% do run_query(drop_query) %}
{% endmacro %}
{% macro create_required_schemas(schema_name) %}
{# required to manually create schemas used for redshift tests #}
{% set schemas_to_drop = get_schemas_used(schema_name) %}
{% set create_query %}
{% for schema in schemas_to_drop %}
create schema if not exists {{schema}};
{% endfor %}
{% endset %}
{% do run_query(create_query) %}
{% endmacro %}
+29
View File
@@ -0,0 +1,29 @@
{% macro f2dq_metric_diff(context) %}
max({{context.column_name}}) - min({{context.column_name}})
{% endmacro %}
{% macro f2dq_metric_my_custom_table_metric(context) %}
1000
{% endmacro %}
{% macro f2dq_metric_regex_test(context) %}
{{ regex_test(context.column_name, context.config.regex) }}
{% endmacro %}
{% macro regex_test(column_name, pattern) %}
coalesce(
sum(
case when {{ f2dq.regex_match_expression(column_name, pattern) }}
then 1
else 0
end
), 0
)
{% endmacro %}
{% macro f2dq_metric_my_distinct_table_rows(context) %}
with temp_table AS (
select distinct * from {{ context.table_name }}
)
select coalesce(count(*), 0) FROM temp_table
{% endmacro %}
+20
View File
@@ -0,0 +1,20 @@
{% macro to_big_integer(field) %}
cast (round({{field}} * 1000) as integer) as {{field}}
{% endmacro %}
{% macro clean_table_name(field) %}
upper(
{{-
f2dq.clean_blacklist(
f2dq.split_and_return_nth_value(field, '.', 3),
['"', '`'],
''
)
-}}
)
{% endmacro %}
{% macro clean_column_name(field) %}
case when ({{ field }} = '' or {{ field }} is null ) then '---' else upper({{field}}) end
{% endmacro %}
@@ -0,0 +1,15 @@
{% macro schema_change_buy_events_add_column() %}
{% set alter_table %}
alter table {{ ref('buy_events')}} add column sample_column boolean
{% endset %}
{% do run_query(alter_table) %}
{% endmacro %}
{% macro schema_change_buy_events_drop_column() %}
{% set alter_table %}
alter table {{ ref('buy_events')}} drop column sample_column
{% endset %}
{% do run_query(alter_table) %}
{% endmacro %}