starburstdata/dbt-trino

Incremental Materialization Macro Uses Variables Before Defined

Closed this issue · 3 comments

Expected behavior

When building an incremental model, the tmp_relation_type inside of the materialization incremental macro should usually resolve to "view."

Actual behavior

The tmp_relation_type resolves to "table."

Steps To Reproduce

Try to build an incremental model and observe what the value of tmp_relation_type is set to in materialization incremental.

Log output/Screenshots

dbt-trino_bug

It can be seen that unique_key and language are defined after get_incremental_tmp_relation_type is called with them as arguments. Additionally but not in the screenshot, incremental_strategy is defined lower in the materialization incremental macro. As such, none of the actual values of these variables are successfully passed into get_incremental_tmp_relation_type, leading to all tmp_relation_types resolving to "table" on account of the logic inside the function.

Operating System

macOS Sonoma 14.5

dbt version

1.8.3

Trino Server version

435-e.5

Python version

3.10.14

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Thanks for noticing! It is indeed a bug. I have already created a PR #418 with a fix for that. It should be merged and released soon

@james-long-mx dbt-trino 1.8.1 has been released! Please update to the latest version, which contains a fix for this bug

Wonderful! Thanks!