Skip to content

Fix running tests with dbt Fusion 2.0.0 preview versions#1948

Merged
tatiana merged 22 commits into
mainfrom
fix-1929
Sep 15, 2025
Merged

Fix running tests with dbt Fusion 2.0.0 preview versions#1948
tatiana merged 22 commits into
mainfrom
fix-1929

Conversation

@tatiana
Copy link
Copy Markdown
Collaborator

@tatiana tatiana commented Sep 5, 2025

The dbt Fusion tests in Cosmos' main branch were failing with errors like:

>           raise CosmosLoadDbtException(f"Unable to run {command} due to the error:\n{details}")
E           cosmos.dbt.graph.CosmosLoadDbtException: Unable to run ['/home/runner/.local/bin/dbt', 'ls', '--output', 'json', '--output-keys', 'name', 'unique_id', 'resource_type', 'depends_on', 'original_file_path', 'tags', 'config', 'freshness', '--project-dir', '/tmp/tmp5viijrkb', '--profiles-dir', '/home/runner/work/astronomer-cosmos/astronomer-cosmos/dev/dags/dbt/jaffle_shop', '--profile', 'snowflake_profile', '--target', 'dev'] due to the error:
E           stderr: error: dbt1060: Ignored unexpected key 'materialized'. Try '+materialized' instead. YAML path: 'jaffle_shop.materialized'.
E             --> dbt_project.yml:24:21
E           error: dbt1060: Ignored unexpected key 'materialized'. Try '+materialized' instead. YAML path: 'jaffle_shop.staging.materialized'.
E             --> dbt_project.yml:26:23
E           error: dbt0102: Deprecated test arguments: ["values"] at top-level detected. Please migrate to the new format under the 'arguments' field: https://docs.getdbt.com/reference/deprecations#missingargumentspropertyingenerictestdeprecation.
E             --> models/schema.yml:58:23
E           error: dbt0102: Deprecated test arguments: ["values"] at top-level detected. Please migrate to the new format under the 'arguments' field: https://docs.getdbt.com/reference/deprecations#missingargumentspropertyingenerictestdeprecation.
E             --> models/staging/schema.yml:20:23
E           error: dbt0102: Deprecated test arguments: ["values"] at top-level detected. Please migrate to the new format under the 'arguments' field: https://docs.getdbt.com/reference/deprecations#missingargumentspropertyingenerictestdeprecation.
E             --> models/staging/schema.yml:31:23
E           
E           stdout: dbt-fusion 2.0.0-preview.3
E              Loading ../../home/runner/work/astronomer-cosmos/astronomer-cosmos/dev/dags/dbt/jaffle_shop/profiles.yml
E              Loading packages.yml
E           suggestion: Run 'dbt deps' to see the latest fusion compatible packages. For compatibility errors, try the autofix script: https://github.com/dbt-labs/dbt-autofix
E             Finished 'ls' target 'dev' with 5 errors in 91ms

Example:
https://github.com/astronomer/astronomer-cosmos/actions/runs/17485309398/job/49663095838?pr=1947

This issue is due to breaking changes introduced in the dbt schema and dbt project syntax as part of the dbt Fusion promotion (and only back-ported to dbt Core 1.10). The latest versions of dbt Fusion no longer accept the previous syntax, which was supported by dbt versions 1.9 and earlier.

This PR:

  • Changes the jaffle_shop so that it is compatible with the new syntax. This has fixed the dbt Fusion tests.
  • For tests that need to run with dbt Core versions before 1.10, modify the DAGs to use altered_jaffle_shop, allowing us to maintain both project syntaxes and validate against both versions. We must support dbt Core 1.9, as it has not yet reached the end of life (https://docs.getdbt.com/docs/dbt-versions/core).

There were a few changes to the CI, and a successful test run against these new configurations can be seen at:
https://github.com/astronomer/astronomer-cosmos/actions/runs/17733688014/job/50390249064

Tests worked with dbt Fusion 2.0.0 preview 13.

Closes: #1929

We may want to make these changes to the altered_project, since I believe the new syntax may not be supported by older versions of dbt, that we also test.

Fix #1929
@netlify
Copy link
Copy Markdown

netlify Bot commented Sep 5, 2025

Deploy Preview for sunny-pastelito-5ecb04 canceled.

Name Link
🔨 Latest commit b111bdc
🔍 Latest deploy log https://app.netlify.com/projects/sunny-pastelito-5ecb04/deploys/68c814db7822ae00083bd3c6

The reason for this is that we changed jaffle_shop to a syntax compatible with dbt fusion (and dbt core 1.10), but this no longer works with previous dbt versions.
Comment thread .github/workflows/test.yml Outdated
https://github.com/astronomer/astronomer-cosmos/actions/runs/17730747169/job/50381228958

cosmos/dev/dags/simple_dag_async.py': 'Traceback (most recent call la...te.name} must only consist of ASCII characters")\nValueError: AssetAlias name must only consist of ASCII characters\n'}
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.04%. Comparing base (1854f9e) to head (4cb37e1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1948   +/-   ##
=======================================
  Coverage   98.04%   98.04%           
=======================================
  Files          86       86           
  Lines        5321     5321           
=======================================
  Hits         5217     5217           
  Misses        104      104           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tatiana tatiana marked this pull request as ready for review September 15, 2025 13:10
Copilot AI review requested due to automatic review settings September 15, 2025 13:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes compatibility issues with dbt Fusion 2.0.0 preview versions by updating the dbt project syntax to use the new format required by dbt Fusion and maintaining backward compatibility for older dbt Core versions.

  • Updates jaffle_shop project syntax to use +materialized instead of materialized and fixes test schema to use the new arguments format
  • Adds environment variable support for specifying different dbt project names to allow testing with both old and new syntax versions
  • Modifies CI configuration to use altered_jaffle_shop for tests with dbt versions before 1.10 while using the updated jaffle_shop for newer versions

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_example_dags.py Adds functions to support testing single DAGs and environment-based project selection
tests/dbt/test_graph.py Updates hash values for cache tests due to project structure changes
scripts/test/integration.sh Excludes simple_dag_async from integration tests
scripts/test/integration-dbt-1-5-4.sh Updates test command format and adds environment variables for older dbt versions
dev/dags/simple_dag_async.py Adds environment variable support for dynamic project path selection
dev/dags/dbt/jaffle_shop/models/staging/schema.yml Updates test syntax to use new arguments format
dev/dags/dbt/jaffle_shop/models/schema.yml Updates test syntax to use new arguments format
dev/dags/dbt/jaffle_shop/dbt_project.yml Updates materialization config to use +materialized prefix
dev/dags/basic_cosmos_task_group.py Adds environment variable support for dynamic project path selection
dev/dags/basic_cosmos_dag_full_module_path_imports.py Adds environment variable support for dynamic project path selection
dev/dags/basic_cosmos_dag.py Adds environment variable support for dynamic project path selection
.github/workflows/test.yml Updates CI configuration to use different projects for different dbt versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread tests/test_example_dags.py
Comment thread scripts/test/integration-dbt-1-5-4.sh
Comment thread .github/workflows/test.yml
Comment thread .github/workflows/test.yml
@tatiana tatiana merged commit f63cba6 into main Sep 15, 2025
73 of 89 checks passed
@tatiana tatiana deleted the fix-1929 branch September 15, 2025 13:30
Copy link
Copy Markdown
Contributor

@pankajkoti pankajkoti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some questions inline.

Comment thread .github/workflows/test.yml
Comment thread .github/workflows/test.yml
Comment on lines +438 to +455
DBT_PROJECT_NAME: "altered_jaffle_shop" # The syntax of jaffle_shop is not supported in dbt 1.5.4, only in dbt >= 1.10
AIRFLOW__COSMOS__ENABLE_DATASET_ALIAS: 0
AIRFLOW_CONN_AWS_S3_CONN: ${{ secrets.AIRFLOW_CONN_AWS_S3_CONN }}
AIRFLOW_CONN_GCP_GS_CONN: ${{ secrets.AIRFLOW_CONN_GCP_GS_CONN }}
AIRFLOW__CORE__DAGBAG_IMPORT_TIMEOUT: 90.0
AIRFLOW__COSMOS__ENABLE_CACHE: 0
AIRFLOW__COSMOS__REMOTE_TARGET_PATH: "s3://cosmos-remote-cache/target_compiled/"
AIRFLOW__COSMOS__REMOTE_TARGET_PATH_CONN_ID: aws_s3_conn
DBT_ADAPTER_VERSION: ${{ matrix.dbt-version }}

# The following are only required because the profiles.yml file references them. They are not used by the tests selected by this job.
AIRFLOW_CONN_EXAMPLE_CONN: postgres://postgres:postgres@0.0.0.0:5432/postgres
POSTGRES_HOST: localhost
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_SCHEMA: public
POSTGRES_PORT: 5432
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we need to move those environment variables here? Our other jobs have most of the environment variables localised to the step that runs the tests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realise we were trying to keep the envvars closer to the step, sorry. We can revert this change in a future change to test.yml! Please, feel free to create a PR with this change

Comment thread .github/workflows/test.yml
Comment thread scripts/test/integration.sh
tatiana added a commit that referenced this pull request Sep 15, 2025
tatiana added a commit that referenced this pull request Sep 15, 2025
Addresses feedback that was posted after merging the PR:
#1948
@tatiana tatiana mentioned this pull request Oct 7, 2025
@tatiana tatiana added this to the Cosmos 1.11.0 milestone Oct 28, 2025
tatiana added a commit that referenced this pull request Oct 29, 2025
**Features**

* Introduce ``ExecutionMode.WATCHER`` to reduce DAG run time by 1/5 in
several PRs. Learn more about it
[here](https://astronomer.github.io/astronomer-cosmos/getting_started/watcher-execution-mode.html#watcher-execution-mode).
This feature was implemented via multiple PRs, including:
* Expose new execution mode by @tatiana @pankajastro @pankajkoti in
#1999
* Add ``DbtProducerWatcherOperator`` for the proposed
``ExecutionMode.WATCHER`` by @pankajkoti in #1982
* Add ``DbtConsumerWatcherSensor`` for the proposed
``ExecutionMode.WATCHER`` by @pankajastro in #1998
* Push producer's task completion status to XCOM by @pankajkoti in #2000
* Add default priority_weight for ``DbtProducerWatcherOperator`` by
@pankajkoti in #1995
* Add sample dbt events for the dbt watcher execution mode by
@pankajkoti in #1952
* Add ``compiled_sql`` as a template fields on
```ExecutionMode.WATCHER``` when using ``run_results.json`` by
@pankajastro in #2070
* Set ``push_run_results_to_xcom`` kwargs correctly for invocation mode
subprocess and Watcher mode by @pankajastro in #2067
* Store compiled SQL as template field for dbt callback events in
``ExecutionMode.WATCHER`` by @pankajkoti in #2068
* Add initial documentation for ``ExecutionMode.WATCHER`` by @tatiana in
#2046
* Support running ``State.UPSTREAM_FAILED`` tasks when WATCHER consumer
upstream tasks fail by @tatiana in #2062
* Fail sensor tasks immediately if the ``ExecutionMode.WATCHER``
producer task fails by @pankajastro in #2040
  * Add ``WATCHER``` to GitHub issue template by @tatiana in #2056
* Add support for ``TestBehavior.AFTER_ALL`` with
``ExecutionMode.WATCHER`` by @pankajastro in #2049
* Add support for ``TestBehavior.NONE`` with ``ExecutionMode.WATCHER``
by @pankajastro in #2047
* Fix ``ExecutionMode.WATCHER`` behaviour with ``DbtTaskGroup`` by
@tatiana in #2044
* Fix Cosmos behaviour when using watcher with
``InvocationMode.DBT_RUNNER`` by @tatiana in #2048

* Add Airflow 3 plugin for dbt docs with multiple dbt projects support
by @pankajkoti in #2009, check the
[documentation](https://astronomer.github.io/astronomer-cosmos/configuration/hosting-docs.html).
* Initial support to ``dbt Fusion`` by @tatiana in #1803. More details
[here](https://astronomer.github.io/astronomer-cosmos/configuration/dbt-fusion).
* Support to prune sources without downstream references in dbt projects
by @corsettigyg in #1988
* Allow to set task display name as a user-defined function by
@corsettigyg in #1761
* Add dbt project's hash to dag docs to support dag versioning in
Airflow 3 by @pankajkoti in #1907
* feat: Add Jinja templating support for ``dbt_cmd_flags`` by
@skillicinski in #1899
* Add Scarf metric to collect the execution mode uses by @pankajastro in
#1981
* Support Airflow 3.1 by @tatiana in #1980
* Add MySQL profile mapping by @Lee2532 in #1977
* Add sqlserver profile mapping by @pankajastro in #1737

**Enhancement**

* Use XCom to store sql when using ``ExecutionMode.AIRFLOW_ASYNC`` by
@pankajastro in #1934
* Refactor ``AIRFLOW_ASYNC`` teardown so it doesn't install the
virtualenv by @pankajastro in #1938
* Reuse the virtual env for ``AIRFLOW_ASYNC`` setup task by @pankajastro
in #1939
* Improve dataset/asset experience in Cosmos by @tatiana in #2030
* Add ``downstreams`` to ``DbtNode`` by @wornjs in #2028

**Bug fixes**

* Fix tags extraction by @ms32035 in #1915
* Fix task flow operator args by @anyapriya in #2024

**Documentation**

* Add documentation for Airflow 3 Plugin supporting dbt docs for
multiple dbt projects by @pankajkoti in #2063
* Add Cosmos Deferrable Operator Guide by @pankajastro in #1922
* Add dbt Fusion documentation by @tatiana in #1824 #1830
* Update dbt-fusion.rst to explicitly highlight it is in alpha by
@tatiana in #1838
* Fix a bunch of docs build errors and warnings by @pankajkoti in
#1886
* Add docs note for param virtualenv_dir for async execution mode by
@pankajastro in #1969
* Use pepy.tech downloads badge in README by @pankajkoti in #1920
* Correct the default value of ``cache_dir`` by @seokyun.ha in #2027

**Others**

* Promote @corsettigyg to committer by @tatiana in #1985
* Add @pankajkoti and @pankajastro to ``contributors.rst`` by @tatiana
in #1983
* Update setup script for airflow3 script by @dwreeves in #2023
* Prevent pytest from trying to test classes that aren't actually tests
by @anyapriya in #2032
* Fix ``dag.test()`` for Airflow 3.1+ by syncing DAG to database bby
@kaxil in #2037
* Disable Scarf in CI by @pankajastro in #2016
* Fix failing dbt Fusion tests when run in parallel in CI by @pankajkoti
in #1896
* Fix MyPy issues related to ``ObjectStoragePath`` in main branch by
@tatiana in #2012
* Cleanup example dbt event JSON dictionaries kept for XCOM referencby
@pankajkoti in #1997
* Bump min hatch version that includes fixes for click>=8.3.0 by
@pankajkoti in #1996
* Use official postgres image from Docker hub for kubernetes setup by
@pankajkoti in #1986
* Use click<8.3.0 for hatch as click 8.3 breaks hatch by @pankajkoti in
#1987
* Pin Airflow version in type check CI job by @pankajastro in #2003
* Improve comments after feedback on #1948 by @tatiana in #1963
* Fix running tests with dbt Fusion 2.0.0 preview versions by @tatiana
in #1948
* Test hardening of dbt node having tags as unset or missing by
@pankajkoti in #1918
* Fix Sphinx issue in the main branch by @tatiana in #2064
* pre-commit autoupdate in #2065, #2043, #2033, #2019, #1990, #2019,
#2008, #1941, #1935, #1924
* GitHub dependabot update in #2051, #2050, #2038, #2022, #1947, #1955,
#1946, #1944, #1945, #1928, #1921, #1917


Co-authored-by: Pankaj Koti <pankaj.koti@astronomer.io>
Co-authored-by: Pankaj Singh <pankaj.singh@astronomer.io>
Co-authored-by: Pankaj Koti <pankajkoti699@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dbt Fusion 2.0.0-preview.3 breaking tests in CI

4 participants