Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADAP-978] [CT-3313] python incremental model tmp_relation_type config #823

Closed
1 of 2 tasks
alireza-moradi opened this issue Nov 2, 2023 · 3 comments
Closed
1 of 2 tasks
Labels
help_wanted Extra attention is needed Stale type:bug Something isn't working

Comments

@alireza-moradi
Copy link

alireza-moradi commented Nov 2, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When tmp_relation_type config is set in project level or model level dbt returns this error :
Python models currently only support 'table' for tmp_relation_type but table was specified.
Even though the tmp_relation_type is set to table.

Expected Behavior

When tmp_relation_type config is set to table dbt should work without any problem. If tmp_relation_type config is set to view then we should get this error.

Steps To Reproduce

  1. In dbt-core==1.6.7 create a python incremental model
  2. set tmp_relation_type config in project level or in model level to table
  3. dbt run -s modelname --full-refresh

Relevant log output

10:32:25  Running with dbt=1.6.7
10:32:25  Registered adapter: snowflake=1.6.5
10:32:25  Found 328 models, 250 tests, 32 seeds, 1 operation, 165 sources, 0 exposures, 0 metrics, 558 macros, 0 groups, 0 semantic models
10:32:25  
10:32:27  Concurrency: 4 threads (target='dev')
10:32:27  
10:32:27  1 of 1 START python incremental model DBT_ALIREZA.testpython ................... [RUN]
10:32:28  1 of 1 ERROR creating python incremental model DBT_ALIREZA.testpython .......... [ERROR in 0.63s]
10:32:28  
10:32:28  
10:32:28  
10:32:28  Finished running 1 incremental model, 1 hook in 0 hours 0 minutes and 2.50 seconds (2.50s).
10:32:28  
10:32:28  Completed with 1 error and 0 warnings:
10:32:28  
10:32:28    Compilation Error in model testpython (models/marts/testpython.py)
  Python models currently only support 'table' for tmp_relation_type but table was specified.
  
  > in macro dbt_snowflake_get_tmp_relation_type (macros/materializations/incremental.sql)
  > called by macro materialization_incremental_snowflake (macros/materializations/incremental.sql)
  > called by model testpython (models/marts/testpython.py)

Environment

- OS: mac
- Python:3.9
- dbt:1.6.7

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@alireza-moradi alireza-moradi added type:bug Something isn't working triage:product labels Nov 2, 2023
@github-actions github-actions bot changed the title python incremental model tmp_relation_type config [CT-3313] python incremental model tmp_relation_type config Nov 2, 2023
@dbeatty10 dbeatty10 self-assigned this Nov 2, 2023
@dbeatty10 dbeatty10 transferred this issue from dbt-labs/dbt-core Nov 2, 2023
@github-actions github-actions bot changed the title [CT-3313] python incremental model tmp_relation_type config [ADAP-978] [CT-3313] python incremental model tmp_relation_type config Nov 2, 2023
@dbeatty10
Copy link
Contributor

Thanks for reporting this @alireza-moradi !

It looks like the problem is here:

  {% if language == "python" and tmp_relation_type is not none %}

And it should be this instead:

  {% if language == "python" and tmp_relation_type is not none and tmp_relation_type != "table" %}

Reprex

models/my_valid_model.py

import pandas


def model(dbt, session):
    dbt.config(
        materialized="incremental",
        tmp_relation_type="table",
    )
    df = pandas.DataFrame([[1,2]] * 3, columns=['column_a', 'column_b'])
    return df

models/my_invalid_model.py

import pandas


def model(dbt, session):
    dbt.config(
        materialized="incremental",
        tmp_relation_type="view",
    )
    df = pandas.DataFrame([[1,2]] * 3, columns=['column_a', 'column_b'])
    return df

This shouldn't work:

dbt run --select my_invalid_model

This should:

dbt run --select my_valid_model

Acceptance criteria

  • dbt-snowflake has functional tests for incremental python models both with each of tmp_relation_type=None, tmp_relation_type="table" and tmp_relation_type="view"
  • at least one of these tests fails without the fix mentioned above
  • include the fix mentioned above within dbt-snowflake

@dbeatty10 dbeatty10 removed their assignment Nov 2, 2023
@nathaniel-may nathaniel-may added the help_wanted Extra attention is needed label Jan 3, 2024
Copy link
Contributor

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 29, 2024
Copy link
Contributor

github-actions bot commented Jan 6, 2025

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help_wanted Extra attention is needed Stale type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants