Skip to content

merge fails when column name conflicts with alias source #1476

Closed

Description

@chriskathumbi

merge fails when column name conflicts with alias source

description

using the spark bigquery connector with dynamic partition overwrite generates a merge query that fails when a column is named source.

the query uses source as both:

  • table alias
  • column name

reproduction

create table `target_table` (
  `id` int64,
  `source` string
);

create table `source_table` (
  `id` int64,
  `source` string
);


merge `target_table` as target
using `source_table` as source
on false
when not matched by target then
insert (`id`, `source`)
values (`id`, `source`);

error

value has type struct which cannot be inserted into column source (string)

cause

spark bigquery connector generates merge with unqualified columns.
source resolves to the alias instead of the column.
this will have similar resolution issue for target

workarounds

  • rename source column
  • avoid dynamic partition overwrite
  • use staging table + custom merge

Activity

  1. added a commit that references this issue on Apr 12, 2026
  2. BoqianShi commented on Apr 12, 2026

    @BoqianShi
    Member

    Hi @chriskathumbi,

    I have merged PR #1477 to resolve this issue by using random UUIDs enclosed in backticks for table aliases in the generated MERGE queries, which avoids conflicts with columns named 'source' or 'target'." It will be available in the upcoming release.

    Thanks for reporting this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ 换网址