Repository navigation
Description
Description
The MatrixOne Python SDK's SQLAlchemy dialect cannot compile many native MySQL scalar type classes that MatrixOne itself supports. Even simple mysql.DATETIME(fsp=6) or mysql.TIME(fsp=6) columns fail before a CREATE TABLE request is sent, preventing normal ORM schema creation and migration.
Environment
- Official MatrixOne
main:5fe08a3307e246e1ab9951ab690b50557af0f509; isolated single-CN service reports8.0.30-MatrixOne-v1.3.0, SQL port36601. - Python SDK
0.1.16from that exact source; Python3.11.14, SQLAlchemy2.0.55. - Standard SQLAlchemy MySQL dialect and isolated MySQL
8.3.0used as controls.
Steps to reproduce
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
from matrixone.sqlalchemy_ext.dialect import MatrixOneDialect
table = sa.Table("sdk_dt_repro", sa.MetaData(),
sa.Column("id", sa.Integer, primary_key=True),
sa.Column("dt", mysql.DATETIME(fsp=6)))
print(sa.schema.CreateTable(table).compile(dialect=MatrixOneDialect()))Repeat with mysql.TIME(fsp=6). In a connected SDK client, table.create(connection) fails identically and creates no table.
Actual behavior
Both cases raise sqlalchemy.exc.CompileError, because MatrixOneTypeCompiler cannot render DATETIME or TIME. Reproduced 3/3 with fresh table names. No failed target table remains; SELECT 1 succeeds and the pool checked-out count is zero after each failure.
Expected behavior / controls
- Standard SQLAlchemy MySQL dialect compiles
DATETIME(6)andTIME(6)successfully. - MatrixOne native SQL can create those two columns and retain a synthetic
.123456microsecond value, 3/3. - Isolated MySQL 8.3 native DDL/insert also succeeds.
Additional same-root compiler matrix
Compilation-only checks with the same SDK dialect also raise CompileError for mysql.YEAR, mysql.BIT(8), mysql.SET, mysql.ENUM, mysql.LONGTEXT, mysql.MEDIUMTEXT, mysql.TINYBLOB, mysql.LONGBLOB, mysql.INTEGER(unsigned=True), mysql.DOUBLE, and mysql.FLOAT. These are presented as one root-cause family, not separate bug reports. The standard MySQL dialect compiles each. Runtime support for each additional type was not separately asserted in this round.
Code analysis
clients/python/matrixone/sqlalchemy_ext/dialect.py: the SQLAlchemy 2.x MatrixOneTypeCompiler inherits generic TypeCompiler, not the MySQL compiler, and manually supplies only some visit_* methods. Missing MySQL-specific visitors cause the unsupported-compilation errors. SQLAlchemy 1.4 has a separate compiler branch; this reproducer specifically validates supported SQLAlchemy 2.0.55.
Regression coverage
Add a parameterized SDK dialect compilation test for native MySQL scalar types and an online create_all/insert/readback case for DATETIME(6), TIME(6), BIT and numeric/blob variants. Preserve a failure cleanup/connection reuse assertion.
Evidence
- Three independent server-side checks and exact output:
/private/tmp/mo-sdk-types-20261026/timestamp_fsp_3x.py. - Same-root type compilation matrix:
/private/tmp/mo-sdk-types-20261026/compiler_matrix.py.
Activity
Ariznawlll commentedon Oct 26, 2026
测试版本
main861a2c4cb68961d8b6b01f18e0aa6ac52a3a505f。5fe08a3307e246e1ab9951ab690b50557af0f509,SQL 端口 36601。原问题验证
补充同根的反射后 DDL 场景:
CREATE TABLE t_f32(id INT PRIMARY KEY, v VECF32(3))后,SDK 的MetaData.reflect(bind=client.get_sqlalchemy_engine(), only=['t_f32'])成功,session.execute(select(reflected_table))返回(1, [1.0, 2.0, 3.0]);但对反射表执行CreateTable(reflected_table).compile(dialect=engine.dialect),3 个新库均报CompileError: ... can't render element of type INTEGER。VECF64(3)表也 3/3 同样失败。这里失败的是已存在表的 ORM schema 再生成,而非原 SQL DDL 或向量读取。Happy Path 覆盖
[1, 2, 3];正式 SDK ORM 范围内的VECF32/F64经反射后可读取并转换成 Python 浮点列表,3/3。Unhappy Path 覆盖
VECF32(3)拒绝为 20301;原有唯一一行完整保留,随后SELECT 42正常,3/3。VECBF16/F16/INT8/UINT8的 ORM 反射另报NullType() takes no arguments,但当前公开 SDKVectorType仅声明 F32/F64;先作为未承诺的支持缺口记录,不并入本 issue 的失败结论。白盒验证
clients/python/matrixone/sqlalchemy_ext/dialect.py的 SQLAlchemy 2.xMatrixOneTypeCompiler继承通用TypeCompiler,只手工委托部分类型;反射返回 MySQLINTEGER类型时缺对应 visitor。这与本 issue 已列出的 MySQL 类型 visitor 缺失同根。本轮未改源码或运行 Go UT。回归测试
本轮未新增仓库测试或 PR。修复时建议在现有 Python SDK 在线反射测试中加入
VECF32/F64(3)+INT PRIMARY KEY的反射→读数→CreateTable编译链,防止只覆盖新建表类型编译。其它未承诺的窄向量类型应先单独确定 SDK 支持合同。测试证据
本地可重复脚本:
/private/tmp/mo-sdk-complete-20261026/orm_vector_reflection_probe.py。三轮每轮创建独立数据库、独立目标表,输出中f32/f64 selected=[(1,[1.0,2.0,3.0])],两者ddl=CompileError ... INTEGER,均执行数据库清理。测试结论
测试不通过。
fix(python-sdk): unify query contracts and atomic manager operations (#…
XuPeng-SH commentedon Oct 26, 2026
Local SDK QA (2026-10-26): SDK source
28e8760905a7f39dba2ce436357ea75492f30512; isolated MatrixOne service binary83c1e23526fc0ed31188abd7fc2ca87cd3a6d4b3(SHA-2566bebe05311ae6438967a824641e3849fbbc9af298003177351794601edf14b4b). Passedtests/online/test_sdk_quality_contracts.py::test_type_metadata_and_valuesfor live DATETIME(6), TIME(6), and TIMESTAMP(6) DDL/value round-trip. Offlinetests.offline.contracts.test_query_contracts::test_scalar_compiler_matches_upstream[type_0..type_18]also passed; the additional MySQL scalar types are compile-only here, not all live runtime cases. This verifies the reported compiler path with those scope limits.Ariznawlll commentedon Oct 26, 2026
测试版本
main;完整 commit:59bad9e8aea4314af30fd25ce53267df5140c8fa。修复 PR #31262 已 MERGED,merge commit28e8760905a7f39dba2ce436357ea75492f30512已核实为此 main 的祖先。mo-serviceSHA-256af1930d6b0fd6d387be01d55635a0ea5dc5f225440234ff942cddebb511078b2,SQL 端口 47011,git_version()=59bad9e8ae;Python 3.12、SQLAlchemy 2.0.55、PyMySQL 1.2.3。测试日期:2026-10-27。原问题验证
此前 SDK 无法编译
mysql.DATETIME(fsp=6)/mysql.TIME(fsp=6),且本 issue 先前 QA 补充了反射表中INTEGERvisitor 缺失。当前 main 上,在线test_type_metadata_and_values在 3 个全新库均成功创建 DATETIME(6)、TIME(6) 并读回2026-01-02 03:04:05.123456和0:00:05.123456,3/3;19 种 MySQL/SQLAlchemy 标量类型与上游 MySQL dialect 的离线编译结果相同,参数化测试 19/19 × 3 轮通过。Happy Path 覆盖
id INT PRIMARY KEY, v VECF32(3)和 VECF64(3),MetaData.reflect后 ORM 读取均为(1, [1.0, 2.0, 3.0]),CreateTable(reflected_table).compile成功生成id INTEGER NOT NULL与v vecf32(3)/vecf64(3);两类均 3/3,不再报INTEGERCompileError。Unhappy Path 覆盖
VECF32(3)插入二维[1,2],3/3 均被 20301 拒绝;原有唯一一行保持,随后SELECT 42返回 42。SELECT 1成功;每轮独立库均删除并核对不存在,连接池无已借出连接。白盒验证
本问题是 SDK SQLAlchemy TypeCompiler 的公开类型编译路径,不是 Go 内部竞态;未运行 Go UT/race。先前 QA 的失败复现与研发最新修复评论均已核对,本次用同一反射→读取→重新编译链独立复验。
回归测试
复用已合入 PR #31262 的 SDK 在线类型合同及离线
test_scalar_compiler_matches_upstream。本轮未新增 MO PR,也未把 SDK TypeCompiler 行为伪装成纯 SQL MOTR #278 回归。PR 的 Python SDK offline 6 个矩阵任务与 CI Required 成功;online CI 被路由跳过,已用本地隔离服务补测。除该 SDK 质量合同文件外,未跑完整 MatrixOne BVT/MOTR/CI;其它未承诺的窄向量 ORM 类型不计入本 issue 结论。测试证据
/private/tmp/mo-six-qa-20261026/qa-night/probe_31204.py,三轮均打印 F32/F64 读取值、生成 DDL、20301 与CLEANED。测试结论
测试通过。