Skip to content

fix: generate valid CLONE SQL in async Python SDK - #27177

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-27087-24fd41d8
Aug 26, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
gouhongshen:agent/issue-27087-24fd41d8

Conversation

@gouhongshen

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #27087

What this PR does / why we need it:

Root cause

The public AsyncCloneManager in clients/python/matrixone/async_client.py had its own SQL construction. It placed IF NOT EXISTS after the destination name and emitted snapshots as FOR SNAPSHOT 'name', while MatrixOne's CLONE grammar requires IF NOT EXISTS before the destination and brace-form snapshot options.

Changes

  • Centralize database/table CLONE SQL construction in BaseCloneManager.
  • Make the legacy async manager reuse that shared builder instead of duplicating SQL assembly.
  • Generate grammar-compatible SQL for both database and table clone operations, including snapshot-only, IF NOT EXISTS-only, and combined options.
  • Preserve the existing brace-form double-quoted snapshot representation already used by the shared clone builder.

Issue-to-test proof

TestAsyncCloneManager now asserts the exact SQL sent to the executor for both database and table cloning across:

  • current-state clone;
  • snapshot clone;
  • IF NOT EXISTS clone; and
  • snapshot plus IF NOT EXISTS (the issue reproduction combination).

A parser-level check also accepted the resulting table/database forms and rejected the legacy FOR SNAPSHOT form.

Tests

  • cd clients/python && python -m pytest tests/offline/ -v --tb=short
  • cd clients/python && python -m pytest tests/offline/test_async_client_query_comprehensive.py -q -k 'TestAsyncCloneManager'
  • cd clients/python && python -m pytest tests/offline/test_clone_builder.py -q
  • cd clients/python && python -m pytest tests/offline/test_sqlalchemy_integration.py -q
  • cd clients/python && python -m pytest tests/offline/test_unified_transaction.py -q
  • PYTHONPATH=clients/python python -m compileall -q clients/python/matrixone/clone.py clients/python/matrixone/async_client.py

The online suite was not run because it requires a live MatrixOne service; this change is covered by deterministic SDK unit tests and the server parser grammar check.

Residual risks

No execution, transaction, or identifier-handling behavior was changed. Snapshot-name escaping remains governed by the SDK's existing interpolation behavior and is outside this issue's scope.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep-reviewed exact head 9093749.

The legacy async manager now reuses the established clone builder, producing the parser-compatible IF NOT EXISTS position and brace-form snapshot option for both DATABASE and TABLE CLONE. The table form is valid because the source table_name nonterminal carries table_snapshot_opt; database CLONE has the corresponding explicit snapshot option. The shared-builder refactor preserves existing sync/unified-async output and does not alter execution, connection, or error lifecycles.

Validation: all 8 focused legacy AsyncCloneManager cases pass, all 29 clone-builder tests pass, compileall passes, diff-check is clean, and exact-head CI is terminal green. No MatrixOne process was started.

@mergify mergify Bot added the queued label Aug 14, 2026
@mergify

mergify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-14 21:36 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-08-14 22:19 UTC · at 90937496cceeea02497745618cefbe64bcc7e083

This pull request spent 42 minutes 18 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

For security reasons, Mergify can't update this pull request. Try updating locally.
GitHub response: refusing to allow a GitHub App to create or update workflow .github/workflows/entrypoint.yaml without workflows permission

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@gouhongshen

Copy link
Copy Markdown
Contributor Author

Mergify's automatic queue check failed because its GitHub App was refused permission to create or update .github/workflows/entrypoint.yaml (workflows permission). This is external to the PR diff and is tracked in #27185. The MatrixOne GitHub Actions checks are terminally successful or skipped; there is no GitHub Actions failure to rerun.

@aptend aptend left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep-reviewed exact head 9093749. The legacy async clone manager now delegates SQL construction to the same BaseCloneManager used by the sync and transaction-aware async implementations. This fixes IF NOT EXISTS placement and emits the parser-supported snapshot option for both database and table clones, while preserving the existing public method signatures and client execution path. The shared builder refactor is output-equivalent for the already-correct managers, and the new tests cover all option combinations. Diff check and Python bytecode compilation pass; the focused test module could not run locally because this checkout lacks pytest, while exact-head CI and another exact-head focused run are green.

@gouhongshen
gouhongshen force-pushed the agent/issue-27087-24fd41d8 branch from 0499bc3 to 2cecdde Compare August 26, 2026 08:44
@gouhongshen
gouhongshen force-pushed the agent/issue-27087-24fd41d8 branch from 2cecdde to 7c18bb4 Compare August 26, 2026 09:19
@gouhongshen
gouhongshen force-pushed the agent/issue-27087-24fd41d8 branch from 7c18bb4 to 96d3b7e Compare August 26, 2026 09:29
@gouhongshen
gouhongshen force-pushed the agent/issue-27087-24fd41d8 branch from 96d3b7e to a10fe9b Compare August 26, 2026 09:52
@mergify

mergify Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-26 12:45 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-26 13:04 UTC · at 09a96c05d3f4a45220873274a4aeb5827b1138e2

This pull request spent 19 minutes 6 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]

Reason

Pull request #27177 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 09a96c05 Deployed Aug 26, 2026 by mergify[bot] via Matrixone Utils CI / Coverage #48465
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: legacy AsyncCloneManager emits CLONE syntax rejected by the server

4 participants