Repository navigation
Description
DRAFT 23 (SDK, 2026-10-27) — filing now
Title: [Bug]: MatrixOneTypeCompiler is never wired — dialect sets attribute "type_compiler" but SQLAlchemy expects "type_compiler_cls"
Description
The MatrixOne SQLAlchemy dialect's 600-line custom type compiler — the code implementing visit_VECTOR (vecf32/vecf64 DDL), DECIMAL scale handling, BIGINT, TIMESTAMP, and dozens of delegating visit_* methods — is dead code, because the wiring uses the wrong attribute name:
# dialect.py:596-597
MatrixOneDialect.statement_compiler = MatrixOneCompiler
MatrixOneDialect.type_compiler = MatrixOneTypeCompiler # ← not a SQLAlchemy hookVerified (pure python, at import time):
MySQLDialect.type_compiler_cls → exists (the real hook)
MySQLDialect.type_compiler → does NOT exist as a dialect hook
MatrixOneDialect.type_compiler_cls → MySQLTypeCompiler ← unchanged! custom class never attached
MatrixOneDialect.type_compiler → MatrixOneTypeCompiler (inert attribute)
Therefore every CREATE TABLE compiled through the dialect silently uses the stock MySQL type compiler, not the MatrixOne one. Consequences observed/derivable:
- Vector columns:
visit_VECTORnever runs. Any type reaching the generic MySQL path renders via the default user-defined-type rendering instead of the intendedvecf32(N)— vector DDL works only because VectorType.get_col_spec happens to also work through a coincidental path (UserDefinedType's defaultvisit_user_defined_typeuses … type-specific rendering); anything relying on the explicit visit_VECTOR branch (e.g. VECTOR without get_col_spec) doesn't. visit_BIGINT/visit_big_integerreturning plain "BIGINT" (dropping MySQL UNSIGNED semantics) — intended MO-tailoring never applies.- The whole 1.4-branch else-arm (
SA_VERSION < (2,0)) plus its own duplicate class at :462 is dead twice over (2.0+ is always taken today). - Diagnostic observation that on SQLAlchemy 2.1.6 a lengthless
String()in CreateTable raisesVARCHAR requires a length on dialect matrixone— the stock MySQL compiler path with the MO dialect name, confirming which compiler is really active.
A secondary twist: had the attribute name been correct, several of the overrides would themselves misfire — e.g. the duplicated visit_timestamp/visit_TIMESTAMP pairs (later def silently shadows earlier), visit_binary calling mysql_compiler.visit_BINARY (wrong method name → AttributeError if ever hit). The class was never exercised, so none of these were ever caught.
Reproduction
from matrixone.sqlalchemy_ext.dialect import MatrixOneDialect, MatrixOneTypeCompiler
print(MatrixOneDialect.type_compiler_cls) # <class MySQLTypeCompiler> ← custom class absent
print(getattr(MatrixOneDialect, 'type_compiler', None)) # the class, attached to a no-op attributeAny version; the wiring simply never worked.
Impact
- The SDK advertises a MatrixOne dialect with tailored type compilation; users actually get stock MySQL type behavior with the MO name. Every type-on-the-edge (unsigned bigint, no-length VARCHAR, 2.x TIMESTAMP variants, vector edge cases) behaves per MySQL rules the SDK authors believed they had overridden.
- Dead 600-line class invites confident-but-wrong future edits (as the duplicated visit methods show); the bug is invisible because nothing errors.
- Same family as the dead-letter API findings from the python-sdk sweep (never-invoked guard rails), but this one sits on the primary DDL path.
Expected behavior
- Wire correctly:
MatrixOneDialect.type_compiler_cls = MatrixOneTypeCompiler(SQLAlchemy's documented hook —Dialect.type_compiler_cls); either delete the inerttype_compilerassignment or keep it only as a deprecation alias. - Delete the SA 1.4 else-branch (SA 2.0+ only in supported range) or gate it on a live distro check.
- De-duplicate the shadowed visit_timestamp/visit_TIMESTAMP pairs, fix
visit_binary's wrong delegate method (visit_BINARYdoesn't exist on the type compiler — should be the right visitor or drop the override). - Add the regression that would have caught all of this in one line:
assert MatrixOneDialect.type_compiler_cls is MatrixOneTypeCompiler, plus a CreateTable compile test with a VectorType column assertingvecf32(N)ends up in the DDL.
Activity
Ariznawlll commentedon Oct 27, 2026
Scope correction after re-checking current main (2026-10-27): the runtime path used by the SDK's own engine creation now applies the type compiler correctly (
dialect.type_compiler_instance = compilerin the dialect install hook), so engine-created flows are NOT affected. The remaining defect is narrower: the module-level class assignments at the bottom of dialect.py still useMatrixOneDialect.type_compiler = MatrixOneTypeCompiler(SQLAlchemy's hook attribute istype_compiler_cls), so anyone instantiatingMatrixOneDialect()directly (tests, third-party dialect registration) gets the stock MySQL type compiler. Downgrading severity per this note; happy either way — class-level fix is one line.fix(python): unify SDK query and analytics lifecycle contracts (#31774)
XuPeng-SH commentedon Oct 30, 2026
QA handoff for merged #31774 (main
bbfe55669a1440424914d45a283a1d0e36f722fa): please verify the public SDK contract and failure/recovery controls for MatrixOneTypeCompiler is dead code — wrong attribute name wires nothing. This isolated QA run inspected the issue and source but did not run functional tests or a live MatrixOne service at this SHA because the existing resource guard left insufficient headroom. Author-reported PR validation is separate evidence, not a result of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。直接实例化的 MatrixOneDialect 已使用 MatrixOneTypeCompiler,生成的向量类型 DDL 可在真实服务执行。
关键证据
main@d39d8a40343ccd40bf665036388df7a40ee867f8;修复 PR fix(python): unify SDK query and analytics lifecycle contracts #31774 合并提交bbfe55669a1440424914d45a283a1d0e36f722fa在祖先链;实际二进制与 SDK 同完整 SHA。本地隔离 1 CN / 1 TN / 1 LogService,Python 3.12、SQLAlchemy 2.0.43。type_compiler_cls与直接实例的 compiler 均为 MatrixOneTypeCompiler;生成 DDL 含vecf32(3)与numeric(10,2)并实际建表。写入[1,2,3]、Decimal12.34和 NULL 后读回正确,列元数据为 vecf32(3)。待解决点
Ariznawlll commentedon Oct 30, 2026
回归位置更正:#295 已关闭并汇总至 MOTR #298;本 issue 的定向用例已补入 #298,之前所述测试结果及未覆盖项不变。#298 尚未合入,完整 MOTR suite 未运行。