Skip to content

Union Relations pulls full SQL to source relation when using microbatch #1059

@moseleyi

Description

@moseleyi

Describe the bug

When using incremental strategy Microbatch the relation gets updated with a WHERE clause and timeframe.

Two things happen:

  1. The code fails
  2. The relation name is full SQL

Steps to reproduce

Create two base models
Create third model that unions the other two using union_relations but make it an incremental model with strategy microbatch

Expected results

_dbt_source_relation should still say db.schema.model_name

Actual results

Error

cast('(select * from "db"."sch"."em_bounces" where partition_date >= '2025-11-10 00:00:00+00:00' and partition_date < '2025-11-11 00:00:00+00:00')' as TEXT) as _dbt_source_relation,

System information

The contents of your packages.yml file:

- name: dbt_utils
    package: dbt-labs/dbt_utils
    version: 1.3.1

Which database are you using dbt with?

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

The output of dbt --version:

Core: 1.10.13
Redshift: 1.9.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions