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:
@@ -0,0 +1,23 @@
|
||||
{# https://github.com/fast2dev/f2dq/issues/143 #}
|
||||
|
||||
{#
|
||||
macro returns rows with she same key set (unique_cols)
|
||||
|
||||
along with the fields of the base model duplicates information added:
|
||||
f2dq_duplicate_count - total number of duplicates with the same current key set
|
||||
f2dq_duplicate_row_number - number of a duplicate row inside the group of duplicates with the same current key set
|
||||
#}
|
||||
|
||||
{% macro filter_get_duplicates(relation, unique_cols, sort_columns) %}
|
||||
(
|
||||
with duplication_context as (
|
||||
{{f2dq.add_duplication_context(relation, unique_cols, sort_columns)}}
|
||||
),
|
||||
duplicate_rows as (
|
||||
select * from duplication_context where f2dq_duplicate_group_row_count > 1
|
||||
)
|
||||
{# return surrogate key as well? #}
|
||||
select *
|
||||
from duplicate_rows
|
||||
)
|
||||
{% endmacro %}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
|
||||
{% macro filter_remove_duplicates(relation, unique_cols, sort_columns) %}
|
||||
(
|
||||
with with_row_num as (
|
||||
{{f2dq.add_duplication_context(relation, unique_cols, sort_columns)}}
|
||||
),
|
||||
one_row_num as (
|
||||
select * from with_row_num where f2dq_duplicate_group_row_number = 1
|
||||
)
|
||||
select {{ dbt_utils.star(from=relation) }}
|
||||
from one_row_num
|
||||
)
|
||||
{% endmacro %}
|
||||
Reference in New Issue
Block a user