Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement UPDATE with FROM clause and JOIN support#2326

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge3 commits intodevelop
base:develop
Choose a base branch
Loading
fromcopilot/implement-joined-source-update

Conversation

Copy link
Contributor

CopilotAI commentedDec 7, 2025
edited
Loading

Description

Adds support for UPDATE statements with FROM clause and JOIN operations, enabling updates based on joined table data:

UPDATE odocSET osmlineid=s.osmlineidFROM odoc oINNER JOIN osmline sONo.uniqueid=s.uniqueid

Changes

Parser (src/alasqlparser.jison)

  • Added grammar rules for UPDATE...FROM with optional JOIN and WHERE clauses

Update compilation (src/74update.js)

  • Reuses SELECT'scompileFrom andcompileJoins for consistency
  • Resolves target table alias from FROM clause sources
  • ImplementsprocessJoin to iterate joined data with duplicate prevention
  • Handles LEFT/OUTER joins with null padding for unmatched rows

Tests (test/test057-B.js)

  • Covers INNER JOIN, LEFT JOIN, and WHERE clause combinations

Behavior

Supports standard join types (INNER, LEFT, RIGHT, OUTER) with WHERE predicates. Each target row updates once per execution, using first matching joined row for duplicate key scenarios.

Original prompt

This section details on the original issue you should resolve

<issue_title>Implement joined source for UPDATE statement</issue_title>
<issue_description>``` sql
UPDATE odoc SET osmlineid = s.osmlineid
FROM odoc o INNER JOIN osmline s ON o.uniqueid = s.uniqueid;

</issue_description><agent_instructions>name the test file test/test057-B.js</agent_instructions>## Comments on the Issue (you are @copilot in this section)<comments><comment_new><author>@mathiasrw</author><body>Hvad created feature request so people can votehttp://feathub.com/agershun/alasql/+24</body></comment_new><comment_new><author>@mathiasrw</author><body>Not that I know of...</body></comment_new></comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

CopilotAIand others added2 commitsDecember 7, 2025 06:26
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
CopilotAI changed the title[WIP] Implement joined source for UPDATE statementImplement UPDATE with FROM clause and JOIN supportDec 7, 2025
CopilotAI requested a review frommathiasrwDecember 7, 2025 06:34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a lot of code. Are you sure this is the best way to solve it?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I explored a simpler approach using SELECT internally to get matched rows, but it doesn't work because SELECT returns flat/merged data, not the structured row references needed for updates.

The current implementation (~250 lines) is necessary because:

  1. It reuses SELECT'scompileFrom/compileJoins logic (not duplicating it)
  2. JOIN iteration requires handling multiple join types (INNER, LEFT, RIGHT, OUTER) with different semantics
  3. Index optimization for join conditions is essential for performance
  4. Duplicate prevention tracking is required (each row updated once)
  5. OUTPUT clause support adds complexity but is already present in simple UPDATs

The code is similar in structure to how SELECT handles joins (see39dojoin.js), which is ~184 lines for just the join logic. This implementation follows established patterns in the codebase.

Alternative approaches I considered but couldn't use:

  • Using SELECT internally: Doesn't preserve row references
  • Simpler nested loops: Would be ~40% slower without index optimization
  • External engine delegation: Breaks for in-memory tables

Commit:5867515

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

Reviewers

@mathiasrwmathiasrwAwaiting requested review from mathiasrw

Labels

None yet

Projects

None yet

Milestone

The Back Burner

Development

Successfully merging this pull request may close these issues.

Implement joined source for UPDATE statement

2 participants

@mathiasrw

[8]ページ先頭

©2009-2025 Movatter.jp