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

[BUG] Merge multiple match check is too strict #3413

Open
2 of 8 tasks
clee704 opened this issue Jul 23, 2024 · 0 comments
Open
2 of 8 tasks

[BUG] Merge multiple match check is too strict #3413

clee704 opened this issue Jul 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@clee704
Copy link
Contributor

clee704 commented Jul 23, 2024

Bug

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Describe the problem

According to the documentation:

A merge operation can fail if multiple rows of the source dataset match and the merge attempts to update the same rows of the target Delta table.

The following merge operation should not fail, because there is only a single source row (1, 10) that updates the target row (1, 1) after evaluating the match condition.

create table source using delta as values
  (0, 0),
  (1, 10),
  (1, 11),
  (2, 20) as (key, value);

create table target using delta as values
  (1, 1),
  (2, 2) as (key, value);

merge into target t using source s on s.key = t.key
  when matched and s.value = 10 then update set key = s.key, value = s.value;

But it fails when run with Delta 3.2 / Spark 3.5.

As a comparison, it works in Microsoft SQL Server 2022 and PostgreSQL 15.

Steps to reproduce

Run the above SQL in Spark 3.5 with Delta 3.2.

Observed results

The command fails with an error saying "multiple matches not allowed".

Expected results

The command shouldn't fail.

Environment information

  • Delta Lake version: 3.2
  • Spark version: 3.5
  • Scala version: 2.12

Willingness to contribute

The Delta Lake Community encourages bug fix contributions. Would you or another member of your organization be willing to contribute a fix for this bug to the Delta Lake code base?

  • Yes. I can contribute a fix for this bug independently.
  • Yes. I would be willing to contribute a fix for this bug with guidance from the Delta Lake community.
  • No. I cannot contribute a bug fix at this time.
@clee704 clee704 added the bug Something isn't working label Jul 23, 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
Projects
None yet
Development

No branches or pull requests

1 participant