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

PostgreSQL - Working with Materialised Views #958

Open
moseleyi opened this issue Oct 15, 2024 · 0 comments
Open

PostgreSQL - Working with Materialised Views #958

moseleyi opened this issue Oct 15, 2024 · 0 comments
Labels
bug Something isn't working triage

Comments

@moseleyi
Copy link

Does the macro work with materialised views in PostgreSQL?

My relations are materialised views but the output of the macro has no columns at all

WITH unioned AS ({{
  dbt_utils.union_relations(
    relations = [
      source("workdocs", "sa_mv"),
      source("workdocs", "sb_mv"),
      source("workdocs", "sf_mv"),
      source("workdocs", "sg_mv"),
      source("workdocs", "sgh_mv"),
      source("workdocs", "sh_mv"),
      source("workdocs", "sh2_mv"),
      source("workdocs", "sh3_mv"),
      source("workdocs", "su_mv"),
      source("workdocs", "suf_mv"),
      source("workdocs", "sw_mv"),
    ]
  )
}}
)

SELECT DISTINCT
  -- This column is definitely in each source view
  vs_nr
FROM unioned

but the result does not contain any columns:

  
    

  create  table "dwh"."dbt_base"."bws__dbt_tmp"
  
  
    as
  
  (
    WITH unioned AS (
    

        (
            select
                cast('"dwh"."wk"."sa_mv"' as TEXT) as _dbt_source_relation,

                

            from "dwh"."wk"."sa_mv"

            
        )

        union all
        

        (
            select
                cast('"dwh"."wk"."sb_mv"' as TEXT) as _dbt_source_relation,

                

            from "dwh"."wk"."sb_mv"

            
        )
@moseleyi moseleyi added bug Something isn't working triage labels Oct 15, 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