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

SNOW-889678: Support MERGE INTO .. USING (SELECT * FROM ( VALUES .. ) ) #435

Open
markfickett opened this issue Aug 9, 2023 · 2 comments
Labels
feature status-triage_done Initial triage done, will be further handled by the driver team

Comments

@markfickett
Copy link

What is the current behavior?

The MergeInto command expects the source to be from an existing table.

What is the desired behavior?

It would be great to have simple syntax for pulling from VALUES.

If there's already a way to do this with a CTE or a temporary table, having an example of that approach in the docs would be very helpful as well.

For example, something like:

from sqlalchemy.sql import Values
from sqlalchemy import column, Integer

source = Values(column('t2key', Integer), column('newval', Integer), name='sq').data([(1, 11), (2, 22), (3, 33)]))
merge = MergeInto(target=t1, source=source, on=t1.c.t1key == source.c.t2key)
merge.when_not_matched_then_insert().values(val=source.c.newval)
num_inserted = connection.execute(merge).scalar()

However, I'm not sure if or how table and column references would work with a Values.

How would this improve snowflake-connector-python?

This would make it easier to use MergeInto when the source data is not already in a table.

References, Other Background

@github-actions github-actions bot changed the title Support MERGE INTO .. USING (SELECT * FROM ( VALUES .. ) ) SNOW-889678: Support MERGE INTO .. USING (SELECT * FROM ( VALUES .. ) ) Aug 9, 2023
@GianlucaGuarroSonos
Copy link

Any update on this? Is the intention for me to create a temporary table with the data I have in my python script and then use this merge into function with this temp table as the source?

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label May 7, 2024
@sfc-gh-dszmolka
Copy link
Contributor

hi all and thank you for this interest in this new capability - at this moment there's no timeline available for the implementation but will update this thread as soon as any new information becomes available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants