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

get_relations_by_pattern does not build downstream tables #966

Open
1 of 5 tasks
jeremy-thomas-roc opened this issue Nov 21, 2024 · 0 comments
Open
1 of 5 tasks

get_relations_by_pattern does not build downstream tables #966

jeremy-thomas-roc opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working triage

Comments

@jeremy-thomas-roc
Copy link

Describe the bug

When using the get_relations_by_pattern macro to populate a table with them in a union, when trying to build the table using the + selector on the model name, it does not build the downstream tables and results in a failed model build.

Steps to reproduce

{{ config(materialized="table") }}

{% set relations = dbt_utils.get_relations_by_pattern(target.schema, "%my%pattern%") %}

with unions as ({{ dbt_utils.union_relations(relations=relations) }})

select *
from unions

Expected results

I would expect to be able to use these macros to generate upstream models without having to manually generate the downstream models, negating the usefulness of this macro. I understand that this macro reads from information_schema (in Snowflake) to populate, but without the ability to generate the models, how would we use this to build upstream models with a single command?

Actual results

Model fails to build because the union_relations macro does not have any relations, creating invalid SQL.

Screenshots and log output

14:58:39    Database Error in model stg_addresses (models/my_model.sql)
  001003 (42000): SQL compilation error:
  syntax error line 11 at position 4 unexpected ')'.
  compiled code at target/run/my_project/models/my_model.sql

Generated file at target/run/my_project/models/my_model.sql:

with unions as (
    )

select *
from unions

System information

The contents of your packages.yml file:

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

Core:
  - installed: 1.8.8
  - latest:    1.8.8 - Up to date!

Plugins:
  - snowflake: 1.8.4 - Up to date!

Additional context

Are you interested in contributing the fix?

With some direction, I have attempted to contribute to dbt before and was not successful. If there is a fix to be made, I am happy to take a shot at it.

@jeremy-thomas-roc jeremy-thomas-roc added bug Something isn't working triage labels Nov 21, 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 triage
Projects
None yet
Development

No branches or pull requests

1 participant