diff --git a/.github/workflows/dbt_run.yml b/.github/workflows/dbt_run.yml index e91f94d53aa..afc1d89b4c7 100644 --- a/.github/workflows/dbt_run.yml +++ b/.github/workflows/dbt_run.yml @@ -48,6 +48,9 @@ jobs: - name: dbt seed run: "dbt seed $PROFILE --select @state:modified --exclude tag:prod_exclude tag:remove --state . --project-dir ${PROJECT_DIR}" + - name: list downstream models + run: "./scripts/list_modified_downstream.sh" + - name: dbt run initial model(s) run: "dbt -x run $PROFILE --select state:modified --exclude tag:prod_exclude tag:remove --defer --state . --project-dir ${PROJECT_DIR}" diff --git a/scripts/list_modified_downstream.sh b/scripts/list_modified_downstream.sh new file mode 100755 index 00000000000..0c7b3b95193 --- /dev/null +++ b/scripts/list_modified_downstream.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Check if required environment variables are set +if [ -z "$PROFILE" ] || [ -z "$PROJECT_DIR" ]; then + echo "Error: PROFILE and PROJECT_DIR environment variables must be set" + echo "Example usage:" + echo "PROFILE=myprofile PROJECT_DIR=/path/to/project ./script.sh" + exit 1 +fi + +# Run dbt command and store output +dbt_output=$(dbt ls $PROFILE \ + --resource-type model \ + --select state:modified+ \ + --output json \ + --output-keys alias schema config \ + --state . \ + --project-dir $PROJECT_DIR) + +# Use jq to parse the JSON and format the output, then sort using sort command +echo "$dbt_output" | \ + jq -r '.[] | "\(.config.materialized // "view") \(.schema) \(.alias)"' | \ + sort | \ + while read -r materialization schema alias; do + echo "[$materialization] - $schema.$alias" + done