Giter VIP home page Giter VIP logo

Comments (11)

abhineetgupta avatar abhineetgupta commented on August 22, 2024 3

I was experiencing the same bug, and at least for me, it was resolved by a dbt run prior to using generate_model_yaml

from dbt-codegen.

trouze avatar trouze commented on August 22, 2024 1

Experienced the same issue using Redshift myself, I figured out a temporary patch that you can clone/use from my fork. The only change I needed to make was in the macro itself, changing the relation variable assignment from:

{% set relation=ref(model_name) %}

to

{% set relation=api.Relation.create(identifier=model_name) %}

@dbeatty10 unsure if this is just a redshift only issue, presumably the ref() function should return a relation object as it is, but I'm starting to cap out my knowledge of the dbt codebase to try an troubleshoot this deeply.

from dbt-codegen.

hiro-o918 avatar hiro-o918 commented on August 22, 2024 1

I also found that generate_base_model has no columns in renamed CTE on BigQuery like the below.

with source as (

    select * from {{ source('foo', 'bar') }}

),

renamed as (

    select

    from source

)

select * from renamed

The operation depends on source to gather column names.

{%- set source_relation = source(source_name, table_name) -%}
{%- set columns = adapter.get_columns_in_relation(source_relation) -%}

On the other hand, generate_source still works correctly because the macro depends on the API, as @trouze described

{% set table_relation=api.Relation.create(
database=database_name,
schema=schema_name,
identifier=table
) %}

So, I think, ref and source cannot collect columns by some reasons.

from dbt-codegen.

NicolasGuary avatar NicolasGuary commented on August 22, 2024 1

Was able to fix this issue by running dbt run --select <model_name> before trying to generate the model's YAML, you sohuld try this !

from dbt-codegen.

jzamanxometry avatar jzamanxometry commented on August 22, 2024 1

So, I had the same issue but on Snowflake. I was missing schema from the source file that we generated, adding it to the source made it work

from dbt-codegen.

hesterluu avatar hesterluu commented on August 22, 2024

I encountered the same issue, running on Redshift.

from dbt-codegen.

dbeatty10 avatar dbeatty10 commented on August 22, 2024

Thanks for opening @pkanter! 🙌

And thank you for the helpful affirmations and work arounds @hesterluu, @abhineetgupta, and @trouze 🧠

Based on the experience of @abhineetgupta, I'm wondering if forcing dependencies is needed.

I'm surprised by the experience reported by @trouze -- if the latter works, I'd expect the former to work also.

from dbt-codegen.

dbeatty10 avatar dbeatty10 commented on August 22, 2024

Thanks for this report @hiro-o918

Are you also using Redshift? Or a different warehouse?

from dbt-codegen.

hiro-o918 avatar hiro-o918 commented on August 22, 2024

Thank you for quick response 🙏
I use BigQuery

from dbt-codegen.

github-actions avatar github-actions commented on August 22, 2024

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.

from dbt-codegen.

github-actions avatar github-actions commented on August 22, 2024

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.

from dbt-codegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.