Skip to content

Elementary dbt package compatibility issue with dbt fusion #2035

@yaragheb

Description

@yaragheb

Describe the bug
Error executing materialization macro dbt_snowflake.materialization_incremental_snowflake when running elementary with dbt fusion

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade elementary package to
- package: elementary-data/elementary
    version: [">=0.20.0", "<0.21.0"]
  1. Make codebase compatible with dbt Fusion
  2. Run elementary package models using dbtf run --select elementary
  3. I get the error
    Failed [  7.12s] model dbt_yragheb_DBT_METADATA.dbt_models (incremental)
error: dbt1501: Error executing materialization macro 'dbt_snowflake.materialization_incremental_snowflake' for model model.elementary.dbt_models: Failed to eval the compiled Jinja expression undefined value
(in compiled/models/edr/dbt_artifacts/dbt_models.sql:1:14)
(in dbt_internal_packages/dbt-snowflake/macros/materializations/incremental.sql:172:3)
(in dbt_internal_packages/dbt-adapters/macros/materializations/hooks.sql:9:23)
(in dbt_internal_packages/dbt-adapters/macros/materializations/hooks.sql:2:1)
(in dbt_packages/elementary/macros/edr/dbt_artifacts/upload_dbt_models.sql:5:25)
(in dbt_packages/elementary/macros/edr/dbt_artifacts/upload_artifacts_to_table.sql:34:33)
(in dbt_packages/elementary/macros/utils/table_operations/delete_and_insert.sql:13:44)
(in dbt_packages/elementary/macros/utils/table_operations/create_intermediate_relation.sql:19:21)
(in dbt_packages/elementary/macros/utils/table_operations/insert_rows.sql:2:31)
(in dbt_packages/elementary/macros/utils/table_operations/insert_rows.sql:31:44)
(in dbt_packages/elementary/macros/utils/table_operations/insert_rows.sql:73:34)
(in dbt_packages/elementary/macros/utils/table_operations/insert_rows.sql:132:19)
(in dbt_packages/elementary/macros/edr/system/system_utils/logs.sql:63:38)
(in dbt_packages/elementary/macros/edr/system/system_utils/logs.sql:109:15)
  --> compiled/models/edr/dbt_artifacts/dbt_models.sql:1:14

Expected behavior
All of the models should run successfully

Screenshots

Image

Environment (please complete the following information):

  • Elementary dbt package version: 0.20.1
  • dbt version you're using: dbt-fusion 2.0.0-preview.45
  • Data warehouse: Snowflake
  • Infrastructure details : MacOS, dev environment

Additional context
When I rerun the command, it runs successfully, so it errors only on the first time.
When I asked claude code to fix it it told me that the issue is that thread_id is being used but never defined in the get_duration_context_stack() macro at line 99-103. This is a known compatibility issue with dbt Fusion.
This is because in dbt Fusion, the global thread_id variable isn't available like it was in older dbt versions.
It also suggested I override the macro and set the default thread to main.

Would you be willing to contribute a fix for this issue?
No

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions