Repository navigation
fix(python-sdk): unify SQL, transaction and driver boundaries - #31889
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review belongs to an older commit; it is not a review of the current head. |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 436b9b4dcc41f67079596413b94c9f0f8e7acbe3
Assessment: request_changes
Two vector DDL regressions remain despite the passing offline suite. Both were reproduced against the merge-base.
Model: gpt-6-astra / xhigh
Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2
-
P2
clients/python/matrixone/sqlalchemy_ext/vector_index.py:1009: Execute CreateIndex for a table with schema='template' on a connection using schema_translate_map={'template': 'tenant_actual'}.
Impact: Reading table.schema directly bypasses SQLAlchemy's schema translation. The index targets the original database, potentially modifying the wrong table or failing during schema creation. Preserve schema-aware formatting while forcing identifier quoting.
Evidence: probes/vector_ddl_boundaries.py uses real SQLAlchemy Connection.execute with a deterministic transport. vector-ddl-probe.log shows HEAD targetingtemplate.vectors, while the merge-base correctly targets tenant_actual.vectors under both format and pyformat. -
P2
clients/python/matrixone/sqlalchemy_ext/vector_index.py:1022: Execute compiled vector-index DDL with a percent-containing index name, such as ix%name, ix%s or ix%%name.
Impact: sql_object_name bypasses the dialect preparer's percent escaping. Driver formatting can fail or silently change the index name. Restore dialect-aware escaping for compiled DDL while retaining correct standalone SQL rendering.
Evidence: vector-ddl-probe.log records ix%name failing before transport, ix%s becoming ix{} with pyformat, and ix%%name becoming ix%name. The same real SQLAlchemy/PyMySQL dispatch probe preserves every name at the merge-base; ordinary-name controls pass at both revisions.
Validation:
-
Isolation preflight passed; receipt checks/1793357612636622390-3.json.
-
Full offline suite: 2787 tests and 95 subtests passed, no skips, on Python 3.13.5 / SQLAlchemy 2.0.43 / aiomysql 0.3.2 / PyMySQL 1.2.3. Receipt checks/1793357642181275349-3.json; offline-2.0.43.log and provenance retained.
-
Baseline/candidate DDL probe confirmed both regressions; receipt checks/1793357740727492551-3.json and vector-ddl-probe.log.
-
All 20 CI scope tests passed; receipt checks/1793357766556935537-3.json.
-
Final audit verified frozen sources, unchanged checkout, complete discussion coverage and receipt/log correspondence; checks/1793357859268795508-3.json.
Limitations:
-
DDL reproductions exercise compilation and driver formatting with a simulated transport, not a native MatrixOne server.
-
Native-server validation remains author-reported. The frozen CI snapshot reports successful Python offline jobs and a skipped online job.
436b9b4 to
637b186
Compare
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 637b186c3097b116dfaf0f7f9f017b1ca8ef04be
Assessment: approve
Both prior vector-DDL findings are resolved: schema translation is preserved and percent-bearing identifiers retain their wire identity. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a1869d-820c-7212-9788-aecfb86a4141 · slot 0 · generation 2
Validation:
-
376 focused tests passed with zero skips on each of SQLAlchemy 1.4.54, 2.0.43 and 2.1.6, including 60 DDL regression cases per version. Receipts and logs are mapped in validation-index.json.
-
The initial SQLAlchemy 2.1.6 environment failure resolved after installing the SDK wheel; all 60 packaged SDK modules match the frozen source.
-
Reviewed all 43 changed files and reconciled all five discussion keys. Verified unchanged prior coverage across 378 SDK/CI files.
-
Final audit passed; source remains unchanged. Review records and validation evidence are retained in the diagnostic directory.
Limitations:
-
Local checks used Python 3.13.5 and deterministic driver transport, not a native server. Native and older-Python qualification remain author-reported evidence.
-
The frozen CI snapshot has online tests skipped.
What type of PR is this?
Which issue(s) this PR fixes:
Closes #30242
Closes #31149
Closes #30059
Closes #31845
Closes #31840
Closes #31404
Closes #31403
Closes #31400
Closes #31399
Closes #31394
What this PR does / why we need it:
Repair the shared Python SDK boundaries behind the ten assigned reports in one change. A duplicate-key COMMIT reply now reports a rejected write with
committed=False; a lost successful reply remains unknown. All search builders quote MATCH identifiers correctly, preserve explicit zero pagination, and share safe native mode rendering. Vector index creation and deletion share validation and execution instead of swallowing failures in repeated paths.build()output. Reject orphan filter parameters even from empty iterators before UPDATE/DELETE generation, and render vector values through the existing literal owner. This closes the shared residual path in [Bug]: Python SQL builder corrupts quoted placeholders and typed values #31149/[Bug]: Python SDK substitutes parameters inside SQL literals and corrupts named prefixes #30059.None, empty metric defaults and future safe index keywords; leave algorithm-specific limits to the server. Share quoted create/drop paths across the three index classes and manager drop. Class/instance execution now raises the original error instead of printing and returningFalse.schema_translate_mapreaches the physical database and percent characters survive the real PyMySQL wire path. Keep MatrixOne reserved identifiers quoted with a compiler-local policy, preserving Table metadata, dialect globals and standalone SQL identity. No per-query work is added.Select.with_snapshotimport side effect. Exportwith_snapshot(statement, name)and retainselect(..., snapshot=...). Applications retaining the method spelling explicitly callenable_snapshot_method()at startup; it is idempotent and refuses to overwrite another owner. Migrate consumers and examples without adding an automatic opt-in.Validation:
bc168358728a, retaining the separate CI matrix-contract correction. Current-code DDL/release/search/vector consumers: 426 passed, zero skipped per environment on SQLAlchemy 1.4.54, 2.0.43 and 2.1.6. Fresh installed wheels byte-match every SDK module and pass the same 426 tests on 1.4.54, 2.0.55/Arrow21 and 2.0.43/PyMySQL1.2.3. The 20 CI scope tests and incremental Black/fatal flake8 pass.bc168358728apasses four native DDL checks, including logical and default-schema translation, percent-containing database/index names verified via SHOW INDEX, create/drop, unchanged rows and existing native failure controls; zero skips. Fixture teardown completes successfully. This is source-fixture evidence, not release-binary certification.gpt-6.1-terra/maxdesign and final overall review; material findings corrected and affected checks repeated.Compatibility: the dependency floor, explicit snapshot-method opt-in and raised index execution errors are intentional corrections documented in the SDK guide. No additional per-query round trip is introduced. Native tests use an owned source fixture, not historical 4.2.5 or other release-binary certification. The fixture could not establish a GBK connection (2013 before encoding); actual-driver GBK/both-mode hex tests pass without claiming a native GBK result. This fixes the bytes compatibility path, not the entire upstream string-encoding advisory; dotted-name fulltext index creation is a separate native limitation, so only its SDK lexical rendering is asserted offline. Remote CI remains pending.