Repository navigation
Description
DRAFT 13 (SDK, 2026-10-27) — to be filed
Title: [Bug]: Session.create_table docstring claims client format but crashes with ArgumentError on string column types
Description
Session.create_table(table_name, columns: dict) (session.py:812) documents: "columns: Dictionary mapping column names to their types (same format as client.create_table)". Client.create_table accepts the string shorthand ('id': 'bigint', 'name': 'varchar(100)', 'embedding': 'vecf32(128)' — per its docstring/example) via a ~120-line string-type parser that maps every supported literal to a SQLAlchemy type.
But the Session implementation does not route through that parser:
builder = VectorTableBuilder(table_name)
for col_name, col_type in columns.items():
is_primary = ...
if is_primary:
builder.add_column(col_name, col_type, primary_key=True) # col_type is "bigint" (str)!
else:
builder.add_column(col_name, col_type)builder.add_column passes the value straight into SQLAlchemy Column(name, type_), which requires a TypeEngine. Verified repro (no server needed):
VectorTableBuilder("t1").add_column("id", "bigint", primary_key=True).build_table()
# sqlalchemy.exc.ArgumentError: 'SchemaItem' object, such as a 'Column' or a
# 'Constraint' expected, got 'bigint'
So every documented usage of Session.create_table with a string-types dict fails at the first column — the documented parity between the two entry points never existed. (Boolean/JSON/vector columns all obviously share the fate.)
The only way it works is passing SQLAlchemy type instances — a format documented nowhere for this method.
Reproduction
with client.session() as s:
s.create_table("users", {
'id': 'bigint',
'name': 'varchar(100)',
}, primary_key='id')
# → sqlalchemy ArgumentError: ... expected, got 'bigint'
# while client.create_table("users", {...}, primary_key='id') succeeds on the same inputImpact
- SDK-on-SDK documentation mismatch: users following the cross-reference ("same format as client.create_table") get an obscure SQLAlchemy internal error mentioning SchemaItem — nothing points to the string-type cause, and nothing suggests reformatting.
- Session-based workflows (the recommended transactional style in the module docstring) lose the quick-DDL feature entirely; teams that started with client.create_table, then moved to sessions for DDL-in-transaction, silently lose working code.
Expected behavior
Session.create_table must reuse the same string-type parser as Client.create_table (factor the ~120-line mapping into a shared helper in e.g. sqlalchemy_ext.table_builder — resolve_column_type(str) -> TypeEngine), so the documented formats are equivalent. Alternatively, if Session intentionally supports only TypeEngine instances, the docstring must stop referencing client format and the TypeError must be raised cleanly (Session.create_table received string type 'bigint'; pass a SQLAlchemy type or use client.create_table).
Add a parity test: for every documented type string, both entry points build the same DDL.
Activity
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 reported public SDK contract and its failure/recovery controls for Session.create_table crashes with ArgumentError on the documented string-type format. This isolated QA run inspected the issue and merged PR but did not run tests or a live MatrixOne service at this SHA because the existing resource guard left insufficient headroom. The PR's author-reported validation is separate evidence, not a result of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。同步和异步 Session.create_table 均能接受原问题里的字符串列类型,正常建表并保持主键。
关键证据
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。id bigint主键和name varchar(100)表,SHOW COLUMNS 确认类型与 PRI;插入后实际读回(1,'alice'),(2,NULL)。not_a_type均拒绝,目标表不存在;每轮测试库清理。MOTR #295 定向 3/3 通过、0 skipped。待解决点