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

Union Relations compilation doesn't include all columns #953

Open
1 of 5 tasks
moseleyi opened this issue Sep 24, 2024 · 0 comments
Open
1 of 5 tasks

Union Relations compilation doesn't include all columns #953

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

Comments

@moseleyi
Copy link

moseleyi commented Sep 24, 2024

From what I read in the documentation, even when relations differ, the macro will result in a list of unique columns from all relations and fill things with NULL when necessary. However, that's not what's happening in my case.

Steps to reproduce

model_a.sql

SELECT
  2 AS test,
  3 AS test2

model_b.sql

SELECT
  1 AS test

Expected results

( 
  SELECT
    CAST('''`project.schema.model_a`''' AS STRING) AS _dbt_source_relation,
    CAST(test AS INT64) AS test,
    CAST(test2 AS INT64) AS test2
  FROM model_a
) UNION ALL
(
  SELECT
    CAST('''`project.schema.model_b`''' AS STRING) AS _dbt_source_relation,
    CAST(test AS INT64) AS test,
    CAST(NULL AS INT64) AS test2
  FROM model_b
)

Actual results

test2 column is not even present in the compiled code

( 
  SELECT
    CAST('''`project.schema.mnodel_a`''' AS STRING) AS _dbt_source_relation,
    CAST(test AS INT64) AS test
  FROM model_a
) UNION ALL
(
  SELECT
    CAST('''`project.schema.mnodel_b`''' AS STRING) AS _dbt_source_relation,
    CAST(test AS INT64) AS test
  FROM model_b
)

System information

The contents of your packages.yml file:

packages:
  - package: dbt-labs/dbt_utils
    version: 1.3.0

Which database are you using dbt with?

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

The output of dbt --version:

Core: 1.8.4
BigQuery: 1.8.2
@moseleyi moseleyi added bug Something isn't working triage labels Sep 24, 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