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

Function adapter.get_columns_in_relation doesn't work if model is materialized as Ephemeral #197

Open
vlnauc opened this issue Oct 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@vlnauc
Copy link

vlnauc commented Oct 29, 2024

Bug Description

I created macro and used function adapter.get_columns_in_relation(model) to get all columns in model, when model is materialized as ephemeral, macro doesn't return any rows, when I change materialization of model to view or table, macro correctly returns all columns in model.

Steps To Reproduce

  1. Create model and define its materialization as ephemeral

  2. Create macro with function adapter.get_columns_in_relation in for cycle to return full list of column of model

{# macros name is no_nulls_in_columns - its used in step 3 #}
{% macro no_nulls_in_columns(model) %}
    SELECT * FROM {{ model }} WHERE
    {% for col in adapter.get_columns_in_relation(model) -%}
        {{ col.column }} IS NULL
        {%- if not loop.last %} OR{% endif %}
    {% endfor %}
{% endmacro %}
  1. Create sql that uses macro and verify generated code, its should contain all columns
{{ no_nulls_in_columns(model) }}

Expected behavior

I expect fuction adapter.get_columns_in_relation(model) return returns full list of column of model no matter if model is materializes as view, table or ephemeral

Screenshots and log output

If applicable, add screenshots or log output to help explain your problem.

The output of dbt --version:

Core:
  - installed: 1.8.7
  - latest:    1.8.8 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - teradata: 1.8.1 - Up to date!

The operating system you're using:
Win 10 Enterprise, Version 22H2
The output of python --version:
Python 3.11.0

@vlnauc vlnauc added the bug Something isn't working label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant