Skip to content

Commit

Permalink
Add clarifying comments to pre-stage filter macros
Browse files Browse the repository at this point in the history
  • Loading branch information
jeancochrane committed Jan 29, 2025
1 parent 83826a1 commit 276c1ee
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dbt/macros/pre_stage_filters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
--
-- Note that the `cur = 'Y'` filter is not necessary in the
-- default.vw_pin_value query that is the main consumer of these macros, since
-- that query already filters rows where `cur = 'Y'`
-- that query already filters rows where `cur = 'Y'`.
--
-- A PIN is in the pre-mailed stage for a year if none of its representations
-- in `asmt_all` in that year have procnames (i.e. stage names). We can check
-- for this status by checking the cardinality of the `stages.procnames` array,
-- where "cardinality" is the Trino SQL equivalent of the length of the array
{% macro pre_mailed_filters(tablename) %}
{{ tablename }}.procname is null
and {{ tablename }}.cur = 'Y'
and cardinality(stages.procnames) = 0
{% endmacro %}

-- A PIN is the pre-certified stage for a year if it has at least one
-- representation in `asmt_all` with a procname (i.e. stage name), but none
-- of its representations in `asmt_all` have the procname that corresponds to
-- the Assessor Certified stage
{% macro pre_certified_filters(tablename) %}
{{ tablename }}.procname is null
and {{ tablename }}.cur = 'Y'
Expand Down

0 comments on commit 276c1ee

Please sign in to comment.