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]: In the MergeInto statement, if a subquery is used for the source table, it cannot correctly identify whether the condition contains the primary key. #3436

Open
2 tasks done
200947912 opened this issue Feb 12, 2025 · 0 comments
Labels
type:bug Something isn't working

Comments

@200947912
Copy link

200947912 commented Feb 12, 2025

What happened?

When using the MergeInto statement, if you execute the filter method after obtaining the references attribute from the Expression object, the Attribute attribute you get will be the column names in the on clause, and you won't be able to correctly obtain the specific columns in the alias table.

Here is an example:

merge into target t using (select id,col from source) source s
on t.id=s.id
when matched then update set a.col = b.col
when not matched then insert *;

In this way, I will get an UnsupportedOperationException. Exception message is "The condition {'a.id, 'b.id} is not allowed because it is not a primary key."

In org.apache.amoro.spark.sql.catalyst.analysis.ResolveMergeIntoMixedFormatTableReferences#checkConditionIsPrimaryKey if using cond.references then i'll get 'a.id with 'b.id,not id#1 or id#2.

Affects Versions

0.7.1

What table formats are you seeing the problem on?

No response

What engines are you seeing the problem on?

No response

How to reproduce

No response

Relevant log output

Anything else

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

  • I agree to follow this project's Code of Conduct
@200947912 200947912 added the type:bug Something isn't working label Feb 12, 2025
200947912 pushed a commit to 200947912/amoro that referenced this issue Feb 13, 2025
200947912 pushed a commit to 200947912/amoro that referenced this issue Feb 19, 2025
 mixed table primarykey(apache#3436)
fixed in merge into statement cannot find
 mixed table primarykey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant