Skip to content

fix(python-sdk): honor enable=False when creating a stage - #31522

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/31389-stage-create-enable
Oct 28, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
MatrixAdventurer:fix/31389-stage-create-enable

Conversation

@MatrixAdventurer

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 #31389

What this PR does / why we need it:

Root cause. StageManager.create() and AsyncStageManager.create() had no enable parameter, _prepare_create() always passed enable=True, and _build_create_stage_sql() ignored the value anyway (# Note: enable is not included in SQL). So there was no way to create a stage that starts disabled, even though the server grammar supports it (create_stage_stmt: CREATE STAGE ... urlparams stage_credentials_opt stage_status_opt stage_comment_opt) and ALTER STAGE in the same file already emits ENABLE=....

The second half of #31389 (unescaped URL / credentials / comment / get_stage WHERE value) is already fixed on main: every value now goes through sql_string_token / sql_literal / sql_object_name. This PR closes the remaining part.

Fix.

  • Add enable: bool = True to the sync and async create() and to _prepare_create(), and pass it through.
  • The builder emits ENABLE=FALSE when enable is False, placed before COMMENT as the grammar requires.
  • enable=True (the default) still emits no clause, so the server keeps its default status (in_use in doCreateStage) and existing SQL is unchanged.

Tests (clients/python/tests/offline/test_stage_sql.py):

  • test_create_stage_disabled_emits_enable_false: sync create(..., enable=False, comment=...) emits CREATE STAGE my_stage URL='file:///data/' ENABLE=FALSE COMMENT='later'.
  • test_async_create_stage_disabled_emits_enable_false: the same check for the async manager.
  • test_create_stage_default_keeps_server_default_status: enable=True still emits the unchanged SQL.

Results:

  • Before the fix, all 3 new tests fail (TypeError: create() got an unexpected keyword argument 'enable'). After the fix, all 3 pass.
  • pytest tests/offline (Python 3.13, run locally): 2289 passed, 95 subtests passed.
  • black --check -l 120 -S and flake8 are clean on the changed files.

2 files, +41/-5.

本操作由 LW 授权的 Grok Bot 智能体执行

StageManager.create and AsyncStageManager.create had no enable
parameter, and the CREATE STAGE builder dropped the one it received,
so a stage meant to start disabled was created usable.

Emit ENABLE=FALSE (before COMMENT, as the grammar requires) when
enable is False. Enabled stays the default and emits no clause, so the
server keeps its default status.

Refs matrixorigin#31389
@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 →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 28, 2026
@XuPeng-SH

XuPeng-SH commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: da6146e900316b429ddb8585500e53c1ae503d88

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: da6146e900316b429ddb8585500e53c1ae503d88

Assessment: approve

The complete delta correctly propagates enable=False through sync and async creation, preserves existing defaults and positional arguments, and follows server clause ordering. Catalog readback remains authoritative. No actionable introduced defects or substantive prior review concerns remain.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • 64 focused repository tests passed; stage-tests.log matches checks/1793165016404656747-3.json.

  • 16 diagnostic SDK tests passed, covering catalog results, session ownership, escaping, errors and cancellation; stage-probe.log matches checks/1793165138550776034-3.json.

  • Baseline control confirmed the previous API rejected enable and preserved existing parameter compatibility; base-control.log matches checks/1793165138356265110-3.json.

  • Verified unchanged server grammar/status handling, clean frozen source and git diff --check. Saved discussion-assessment.json and validation-manifest.json under /home/xupeng/.local/state/mo-bot/jobs/4da80d43745266e565668fc7/attempt-1; evidence-audit.log matches checks/1793165350257743416-4.json.

Limitations:

  • Validation used Python 3.13.5 and SQLAlchemy 2.1.6 with executor doubles; no live-server run or full offline suite was performed.

  • SDK escaping predates this change. The linked issue's broader quoted-value catalog round-trips are not established here; existing frontend name restrictions and catalog interpolation remain unchanged.

@mergify mergify Bot added the queued label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 1966c41 at 05:57 UTC

27 min in the queue, 2 min of it CI.

So far

  • ✅ Entered the queue Wed 28 Oct, 05:30 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 05:57 · 1966c41 · squash
Merge conditions: 3 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
✅ any of: check-success = CI Required, check-neutral = CI Required, check-skipped = CI Required GitHub branch protection

Times in UTC · dashboard · how the merge queue works

@mergify
mergify Bot requested a review from aptend as a code owner October 28, 2026 05:54
@mergify
mergify Bot merged commit 1966c41 into matrixorigin:main Oct 28, 2026
29 of 30 checks passed
@mergify mergify Bot removed the queued label Oct 28, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: StageManager drops enable=False on CREATE; URLs/credentials/comment interpolated unescaped

2 participants