ydb-platform / ydb-platform/ydb-sqlalchemy
Bug: Incorrect SQL generated for `UPSERT INTO ... SELECT`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 40
- Forks
- 13
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Hi guys,
Thank you for the great work on this library.
I've encountered an issue where UPSERT INTO ... SELECT FROM generates invalid YQL. This also likely affects INSERT INTO ... SELECT. YDB supports this syntax natively (UPSERT docs, INSERT docs), but the generated query fails because it incorrectly includes the target table in the FROM clause.
Example of the faulty generated query:
UPSERT INTO my_table (col1, col2)
SELECT my_table.col1, my_table.col2
FROM as_table(%(my_input)s), my_table
The extra my_table in the FROM clause and columns in brackets causes the query to fail. Could you please look into fixing the query generation logic?
Thanks for your help!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the SQL generation logic for UPSERT INTO ... SELECT and compare it with the INSERT INTO ... SELECT path. Use the faulty query and the linked YDB UPSERT and INSERT documentation as references; done means the generated YQL omits the target table from FROM and avoids the invalid column brackets for both forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100