From 1d03b481b79c9e16e522ccb5cc0c9efec09ee720 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Wed, 1 Apr 2026 09:48:49 -0400 Subject: [PATCH 01/11] rename file to align with cli name --- dcpy/lifecycle/scripts/_cli.py | 2 +- ...st_with_library_fallback.py => ingest_or_library_archive.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename dcpy/lifecycle/scripts/{ingest_with_library_fallback.py => ingest_or_library_archive.py} (100%) diff --git a/dcpy/lifecycle/scripts/_cli.py b/dcpy/lifecycle/scripts/_cli.py index 49a2eabace..311cddd61f 100644 --- a/dcpy/lifecycle/scripts/_cli.py +++ b/dcpy/lifecycle/scripts/_cli.py @@ -1,7 +1,7 @@ import typer from .compare_build_tables import app as compare_build_tables_app -from .ingest_with_library_fallback import run as ingest_or_library_archive +from .ingest_or_library_archive import run as ingest_or_library_archive from .package_and_distribute import app as package_dist_app from .product_metadata import app as product_metadata_app from .validate_ingest import app as ingest_validation_app diff --git a/dcpy/lifecycle/scripts/ingest_with_library_fallback.py b/dcpy/lifecycle/scripts/ingest_or_library_archive.py similarity index 100% rename from dcpy/lifecycle/scripts/ingest_with_library_fallback.py rename to dcpy/lifecycle/scripts/ingest_or_library_archive.py From 25b2c9d13b1930420622209cd385d3059d8eaeba Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Fri, 27 Mar 2026 15:12:33 -0400 Subject: [PATCH 02/11] set CBBR version to FY2027 --- products/cbbr/recipe.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/cbbr/recipe.yml b/products/cbbr/recipe.yml index b734d3c47c..bb161eb302 100644 --- a/products/cbbr/recipe.yml +++ b/products/cbbr/recipe.yml @@ -1,6 +1,6 @@ name: Community Board Budget Requests product: db-cbbr -version: FY2026 +version: FY2027 inputs: missing_versions_strategy: find_latest datasets: From da2298043161430b3d92aaa7d4dd40be78bcec43 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Fri, 27 Mar 2026 15:18:34 -0400 Subject: [PATCH 03/11] use s3 for CBBR source data --- ingest_templates/dcp_cbbr_requests.yml | 8 +++++--- ingest_templates/omb_cbbr_agency_responses.yml | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ingest_templates/dcp_cbbr_requests.yml b/ingest_templates/dcp_cbbr_requests.yml index 5456b32745..4a4c4acef6 100644 --- a/ingest_templates/dcp_cbbr_requests.yml +++ b/ingest_templates/dcp_cbbr_requests.yml @@ -17,10 +17,12 @@ attributes: ingestion: source: - type: local_file - path: ./dcp_cbbr_requests.csv + type: s3 + bucket: edm-recipes + key: inbox/dcp/dcp_cbbr_requests/{{ version }} BRs for Data Engineering (All Boards).csv file_format: type: csv + dtype: str processing_steps: - name: clean_column_names - args: { "replace": { " -": "", "-": "_", " ": "_" }, "lower": True } + args: { "replace": { "-": "_", " ": "_" }, "lower": True } diff --git a/ingest_templates/omb_cbbr_agency_responses.yml b/ingest_templates/omb_cbbr_agency_responses.yml index d94c6016e0..b8c33698f2 100644 --- a/ingest_templates/omb_cbbr_agency_responses.yml +++ b/ingest_templates/omb_cbbr_agency_responses.yml @@ -15,10 +15,13 @@ attributes: ingestion: source: - type: local_file - path: ./omb_cbbr_agency_responses.csv + type: s3 + bucket: edm-recipes + key: inbox/dcp/omb_cbbr_agency_responses/{{ version }} OMB Raw Export.xlsx file_format: - type: csv + type: xlsx + sheet_name: AGCY reponses + dtype: str processing_steps: - name: clean_column_names args: { "replace": { " ": "_" }, "lower": True } From 68a488ec5aa9da5cebd210da08dd67f9898fd13e Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Tue, 31 Mar 2026 15:34:21 -0400 Subject: [PATCH 04/11] fix source columns --- products/cbbr/sql/cbbr_submissions.sql | 18 +++++++++--------- products/cbbr/sql/export.sql | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/products/cbbr/sql/cbbr_submissions.sql b/products/cbbr/sql/cbbr_submissions.sql index 3c12bfe606..b06ef39be8 100644 --- a/products/cbbr/sql/cbbr_submissions.sql +++ b/products/cbbr/sql/cbbr_submissions.sql @@ -14,18 +14,18 @@ SELECT dcp.policy_area, dcp.need_group, dcp.need, - dcp.budget_request_title AS title, + dcp.budget_request_title_please_give_your_budget_request_a_short_an AS title, dcp.request, -- TODO - should probably just use dcp.explanation but clean special charactesr REPLACE(omb.reason, E'\n', ' ') AS explanation, - dcp.location_specific, - dcp.address, - dcp.site_or_facility_name, - dcp.on_street, - dcp.cross_street_1, - dcp.cross_street_2, - dcp.intersection_street_1, - dcp.intersection_street_2, + dcp."is_this_request_specific_to_a_particular_site,_location,_or_fac" AS location_specific, + dcp."address:request_location_(complete_all_that_apply)_for_addresse" AS address, + dcp."site_or_facility_name:request_location_(complete_all_that_apply" AS site_or_facility_name, + dcp."on_street_(enter_street_name):complete_the_following_if_your_re" AS on_street, + dcp."cross_street_1_(for_street_segment):request_location_(complete_" AS cross_street_1, + dcp."cross_street_2_(for_street_segment):request_location_(complete_" AS cross_street_2, + dcp."intersection___street_1:complete_the_following_if_your_request_" AS intersection_street_1, + dcp."intersection___street_2:complete_the_following_if_your_request_" AS intersection_street_2, omb.lowsgrp1 AS supporters_1, omb.lowsgrp2 AS supporters_2, omb.capis1 AS project_id_1, -- all null diff --git a/products/cbbr/sql/export.sql b/products/cbbr/sql/export.sql index e6451c73d2..53b85ceabb 100644 --- a/products/cbbr/sql/export.sql +++ b/products/cbbr/sql/export.sql @@ -101,7 +101,7 @@ SELECT commdist, cb_label, type_br, - -- type, + type, priority, policy_area, need_group, From ff28bfc0417833a39ab143c6978aa587c7bd905e Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Fri, 3 Apr 2026 12:33:42 -0400 Subject: [PATCH 05/11] start using latest agency lookup --- products/cbbr/recipe.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/products/cbbr/recipe.yml b/products/cbbr/recipe.yml index bb161eb302..41beeda165 100644 --- a/products/cbbr/recipe.yml +++ b/products/cbbr/recipe.yml @@ -12,3 +12,5 @@ inputs: - name: dpr_parksproperties - name: dcp_facilities - name: doitt_buildingfootprints + # other data + - name: dcp_managing_agencies_lookup From 19f6feab77200566cb2b5b3ebdd11dd11a20d261 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Fri, 3 Apr 2026 12:28:51 -0400 Subject: [PATCH 06/11] start to dbtify CBBR --- .github/workflows/cbbr_build.yml | 12 ++++++++++-- products/cbbr/dbt_project.yml | 10 ++++++++++ products/cbbr/packages.yml | 7 +++++++ products/cbbr/profiles.yml | 11 +++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 products/cbbr/dbt_project.yml create mode 100644 products/cbbr/packages.yml create mode 100644 products/cbbr/profiles.yml diff --git a/.github/workflows/cbbr_build.yml b/.github/workflows/cbbr_build.yml index 14f02eab18..70a82f6350 100644 --- a/.github/workflows/cbbr_build.yml +++ b/.github/workflows/cbbr_build.yml @@ -56,7 +56,10 @@ jobs: AWS_SECRET_ACCESS_KEY: "op://Data Engineering/DO_keys/AWS_SECRET_ACCESS_KEY" AWS_ACCESS_KEY_ID: "op://Data Engineering/DO_keys/AWS_ACCESS_KEY_ID" BUILD_ENGINE_SERVER: "op://Data Engineering/EDM_DATA/server_url" - EDM_DATA: "op://Data Engineering/EDM_DATA/defaultdb_url" + BUILD_ENGINE_HOST: "op://Data Engineering/EDM_DATA/server" + BUILD_ENGINE_USER: "op://Data Engineering/EDM_DATA/username" + BUILD_ENGINE_PASSWORD: "op://Data Engineering/EDM_DATA/password" + BUILD_ENGINE_PORT: "op://Data Engineering/EDM_DATA/port" - name: Finish container setup ... working-directory: ./ @@ -71,11 +74,16 @@ jobs: - name: Set recipe env vars working-directory: ./ - run: source ./bash/export_recipe_env.sh products/cbbr/${{ inputs.recipe_file }}.lock.yml + run: source ./bash/export_recipe_env.sh products/cbbr/${{ inputs.recipe_file }}.lock.yml - name: Dataloading run: python3 -m dcpy lifecycle builds load load + - name: Build + run: | + dbt deps + dbt debug + - name: Create Build Tables and Normalize CBBR Values run: ./02_cbbr.sh diff --git a/products/cbbr/dbt_project.yml b/products/cbbr/dbt_project.yml new file mode 100644 index 0000000000..83741120f5 --- /dev/null +++ b/products/cbbr/dbt_project.yml @@ -0,0 +1,10 @@ +name: "cbbr" + +profile: "dcp-de-postgres" + +model-paths: [ "models" ] +test-paths: [ "tests" ] + +tests: + +store_failures: true + +schema: "_tests" diff --git a/products/cbbr/packages.yml b/products/cbbr/packages.yml new file mode 100644 index 0000000000..554aa6a260 --- /dev/null +++ b/products/cbbr/packages.yml @@ -0,0 +1,7 @@ +packages: +- package: dbt-labs/dbt_utils + version: 1.3.3 +- package: dbt-labs/audit_helper + version: 0.13.0 +- package: metaplane/dbt_expectations + version: 0.10.10 diff --git a/products/cbbr/profiles.yml b/products/cbbr/profiles.yml new file mode 100644 index 0000000000..6712525864 --- /dev/null +++ b/products/cbbr/profiles.yml @@ -0,0 +1,11 @@ +dcp-de-postgres: + target: dev + outputs: + dev: + type: postgres + host: "{{ env_var('BUILD_ENGINE_HOST') }}" + user: "{{ env_var('BUILD_ENGINE_USER') }}" + password: "{{ env_var('BUILD_ENGINE_PASSWORD') }}" + port: "{{ env_var('BUILD_ENGINE_PORT') | as_number }}" + dbname: "{{ env_var('BUILD_ENGINE_DB') }}" + schema: "{{ env_var('BUILD_ENGINE_SCHEMA') }}" From 6f53ae7f2775309a02d00cb526d86d3fc2bf6e80 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Fri, 3 Apr 2026 12:29:10 -0400 Subject: [PATCH 07/11] start staging models --- products/cbbr/02_cbbr.sh | 1 + products/cbbr/models/_sources.yml | 6 ++++++ products/cbbr/models/staging/_staging.yml | 9 +++++++++ .../models/staging/stg__doitt_buildingfootprints.sql | 4 ++++ products/cbbr/sql/assign_geoms.sql | 6 +++--- 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 products/cbbr/models/_sources.yml create mode 100644 products/cbbr/models/staging/_staging.yml create mode 100644 products/cbbr/models/staging/stg__doitt_buildingfootprints.sql diff --git a/products/cbbr/02_cbbr.sh b/products/cbbr/02_cbbr.sh index acdb822875..b138b4ce13 100755 --- a/products/cbbr/02_cbbr.sh +++ b/products/cbbr/02_cbbr.sh @@ -6,6 +6,7 @@ echo "CBBR Version ${VERSION} : 02 CBBR" # TODO delete tables that are created by this stage echo "Create build tables to modify ..." +dbt build --select staging run_sql_file sql/preprocessing.sql run_sql_file sql/cbbr_submissions.sql diff --git a/products/cbbr/models/_sources.yml b/products/cbbr/models/_sources.yml new file mode 100644 index 0000000000..17995a2b2b --- /dev/null +++ b/products/cbbr/models/_sources.yml @@ -0,0 +1,6 @@ +sources: + - name: recipe_sources + schema: "{{ env_var('BUILD_ENGINE_SCHEMA') }}" + tables: + - name: source_data_versions + - name: doitt_buildingfootprints diff --git a/products/cbbr/models/staging/_staging.yml b/products/cbbr/models/staging/_staging.yml new file mode 100644 index 0000000000..a58b78b527 --- /dev/null +++ b/products/cbbr/models/staging/_staging.yml @@ -0,0 +1,9 @@ +models: + - name: stg__doitt_buildingfootprints + columns: + - name: base_bbl + tests: [ not_null ] + - name: bin + tests: [ not_null ] + - name: geom + tests: [ not_null ] diff --git a/products/cbbr/models/staging/stg__doitt_buildingfootprints.sql b/products/cbbr/models/staging/stg__doitt_buildingfootprints.sql new file mode 100644 index 0000000000..b56c5720e4 --- /dev/null +++ b/products/cbbr/models/staging/stg__doitt_buildingfootprints.sql @@ -0,0 +1,4 @@ +select + *, + wkb_geometry as geom +from {{ source('recipe_sources', 'doitt_buildingfootprints') }} diff --git a/products/cbbr/sql/assign_geoms.sql b/products/cbbr/sql/assign_geoms.sql index b9c3a86b71..1b8366132e 100644 --- a/products/cbbr/sql/assign_geoms.sql +++ b/products/cbbr/sql/assign_geoms.sql @@ -25,14 +25,14 @@ SET geom = ( CASE WHEN a.geo_bbl || a.geo_bin IS NOT NULL - THEN st_centroid(b.geom) + THEN st_centroid(footprints.geom) ELSE a.geom END ) FROM - _doitt_buildingfootprints AS b + stg__doitt_buildingfootprints AS footprints WHERE - a.geo_bbl || a.geo_bin = b.base_bbl || b.bin; + a.geo_bbl || a.geo_bin = footprints.base_bbl || footprints.bin; -- Convert from_x_coord, from_y_coord to from_geom -- Convert to_x_coord, to_y_coord to to_geom From 9a45e469f3e7e9c9906b423579750e14dc43b4b5 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Mon, 13 Apr 2026 11:38:29 -0400 Subject: [PATCH 08/11] fix missing Staten Island values --- products/cbbr/sql/normalize_commdist.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/cbbr/sql/normalize_commdist.sql b/products/cbbr/sql/normalize_commdist.sql index d741e9b82c..9c2e5084d6 100644 --- a/products/cbbr/sql/normalize_commdist.sql +++ b/products/cbbr/sql/normalize_commdist.sql @@ -50,5 +50,5 @@ SET borough_code = '5', commdist = '5' || lpad(cd, 2, '0') WHERE - a.borough = 'SI' + a.borough = 'Staten Island' AND commdist IS NULL; From df485aee98c1f03220f91c9c92a5d4a3980f415a Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Thu, 16 Apr 2026 11:46:17 -0400 Subject: [PATCH 09/11] trim whitespace --- products/cbbr/sql/cbbr_submissions.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/products/cbbr/sql/cbbr_submissions.sql b/products/cbbr/sql/cbbr_submissions.sql index b06ef39be8..d3680183b4 100644 --- a/products/cbbr/sql/cbbr_submissions.sql +++ b/products/cbbr/sql/cbbr_submissions.sql @@ -4,7 +4,7 @@ DROP TABLE IF EXISTS _cbbr_submissions; CREATE TABLE _cbbr_submissions AS SELECT omb.dcpuniqid AS unique_id, - omb.trkno AS tracking_code, + TRIM(omb.trkno) AS tracking_code, omb.borough, RIGHT(omb.cb_label, 2) AS cd, omb.cb_label, From 7de494186b944253f02c28477f59d2f30c17aa95 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Thu, 16 Apr 2026 16:18:31 -0400 Subject: [PATCH 10/11] drop tranform of unused column --- products/cbbr/02_cbbr.sh | 3 --- products/cbbr/sql/normalize_denominator.sql | 23 --------------------- 2 files changed, 26 deletions(-) delete mode 100644 products/cbbr/sql/normalize_denominator.sql diff --git a/products/cbbr/02_cbbr.sh b/products/cbbr/02_cbbr.sh index b138b4ce13..88de5a2d0f 100755 --- a/products/cbbr/02_cbbr.sh +++ b/products/cbbr/02_cbbr.sh @@ -16,7 +16,4 @@ run_sql_file sql/normalize_agency.sql echo "Normalize commdist values ..." run_sql_file sql/normalize_commdist.sql -echo "Normalize denominator values ..." -run_sql_file sql/normalize_denominator.sql - echo "Done!" diff --git a/products/cbbr/sql/normalize_denominator.sql b/products/cbbr/sql/normalize_denominator.sql deleted file mode 100644 index 8bed641984..0000000000 --- a/products/cbbr/sql/normalize_denominator.sql +++ /dev/null @@ -1,23 +0,0 @@ -ALTER TABLE _cbbr_submissions -DROP COLUMN IF EXISTS denominator; - -ALTER TABLE _cbbr_submissions -ADD COLUMN denominator text; - -WITH denominatorcount AS ( - SELECT - commdist, - type_br, - COUNT(*) AS count - FROM - _cbbr_submissions - GROUP BY - commdist, - type_br -) -UPDATE _cbbr_submissions a -SET denominator = b.count -FROM denominatorcount AS b -WHERE - a.commdist = b.commdist - AND a.type_br = b.type_br; From 55fb631f96e6026100174161467cc2477b86bdc7 Mon Sep 17 00:00:00 2001 From: Damon McCullough Date: Thu, 16 Apr 2026 16:51:20 -0400 Subject: [PATCH 11/11] add normalization for request values --- products/cbbr/02_cbbr.sh | 5 +++++ products/cbbr/models/intermediate/_cbbr_submissions.sql | 1 + products/cbbr/models/intermediate/_intermediate.yml | 5 +++++ products/cbbr/sql/normalize_requests.sql | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100644 products/cbbr/models/intermediate/_cbbr_submissions.sql create mode 100644 products/cbbr/models/intermediate/_intermediate.yml create mode 100644 products/cbbr/sql/normalize_requests.sql diff --git a/products/cbbr/02_cbbr.sh b/products/cbbr/02_cbbr.sh index 88de5a2d0f..e82edac900 100755 --- a/products/cbbr/02_cbbr.sh +++ b/products/cbbr/02_cbbr.sh @@ -16,4 +16,9 @@ run_sql_file sql/normalize_agency.sql echo "Normalize commdist values ..." run_sql_file sql/normalize_commdist.sql +echo "Normalize request values ..." +run_sql_file sql/normalize_requests.sql + +dbt test --select intermediate + echo "Done!" diff --git a/products/cbbr/models/intermediate/_cbbr_submissions.sql b/products/cbbr/models/intermediate/_cbbr_submissions.sql new file mode 100644 index 0000000000..da4b99af97 --- /dev/null +++ b/products/cbbr/models/intermediate/_cbbr_submissions.sql @@ -0,0 +1 @@ +-- PLACEHOLDER diff --git a/products/cbbr/models/intermediate/_intermediate.yml b/products/cbbr/models/intermediate/_intermediate.yml new file mode 100644 index 0000000000..4e818e4ed0 --- /dev/null +++ b/products/cbbr/models/intermediate/_intermediate.yml @@ -0,0 +1,5 @@ +models: + - name: _cbbr_submissions + columns: + - name: need + tests: [ not_null ] diff --git a/products/cbbr/sql/normalize_requests.sql b/products/cbbr/sql/normalize_requests.sql new file mode 100644 index 0000000000..437041e83f --- /dev/null +++ b/products/cbbr/sql/normalize_requests.sql @@ -0,0 +1,9 @@ +UPDATE _cbbr_submissions a +SET + policy_area = 'Other Needs', + need_group = 'Other', + need = 'Other Capital Needs' +WHERE + need IS NULL + AND agency_acronym = 'DSNY' + AND type = 'Capital';