Repository navigation
Closed
Copy link
Description
DRAFT 22 (SDK, 2026-10-27) — to be filed
Title: [Bug]: vector index create passes str(Column) ("Doc.id") into DDL — documented Column-object input produces invalid SQL
Description
IVFFLATVectorIndex / HNSWVectorIndex (sqlalchemy_ext/vector_index.py) accept column: Union[str, Column] and normalize it with:
self._column_name = str(column) if not isinstance(column, str) else column
...
sql_parts = [f"CREATE INDEX {self.name} USING {self.index_type} ON {table_name}({column_name})"]But str() of a SQLAlchemy Column is not the column name — verified on the repo's own SQLAlchemy version:
>>> str(Doc.id) # ORM mapped attribute
'Doc.id' # class-qualified
>>> str(Doc.__table__.c.id) # Table-level Column
'docs.id' # table-qualifiedSo every documented Column-object invocation emits broken DDL:
IVFFLATVectorIndex.create_index(engine, "docs", "ft", Doc.embedding, lists=100)
# CREATE INDEX ft USING ivfflat ON docs(Doc.id) LISTS 100 ...
# ^^^^^^ unknown column "Doc.id" → server error
# (or quietly wrong if a dot-containing identifier ever matches)Same defect in HNSWVectorIndex (same _column_name = str(column) line) and in the drop path implicitly (drop uses only name/table, fine).
Additionally in the same builders (for the same fix, not the main defect):
name/table_name/op_typeare interpolated unescaped (family issue, one more site),- numeric knobs (
lists,m,ef_construction,ef_search) are unvalidated ints interpolated raw — client-side sanity checks absent, create_index/drop_indexwrap failures inprint(...)+return False— the same error-swallowing pattern filed for FulltextIndex today ([Bug]: fulltext create_index swallows server errors with print() #31382); consolidating that observation here so the fix PR can convert all three helpers to raising/logging at once.
Reproduction
from sqlalchemy import Column, Integer, Text
from sqlalchemy.orm import declarative_base
from matrixone.sqlalchemy_ext.vector_index import IVFFLATVectorIndex
Base = declarative_base()
class Doc(Base):
__tablename__ = "docs"
id = Column(Integer, primary_key=True)
body = Column(Text)
idx = IVFFLATVectorIndex("ft", Doc.body) # documented Union[str, Column] usage
print(idx._column_name) # 'Doc.body' ← not 'body'!
idx.create_sql("docs")
# 'CREATE INDEX ft USING ivfflat ON docs(Doc.body) LISTS 100 op_type 'vector_l2_ops''
# server → unknown column 'Doc.body'Pure-python verification of the str() behavior needs no server.
Impact
- The natural, autocomplete-friendly call style (
Doc.embeddingrather than"embedding") — precisely the audience a SQLAlchemy integration targets — fails 100% of the time with a server-side unknown-column error that never mentions the real cause (str-vs-name conversion).<class>.<attr>shapes even look plausible in error logs. - ORM users' first touchpoint with the SDK vector stack breaks; workarounds (string column) are undocumented.
Expected behavior
- Normalize Column objects via
column.name(or.key), e.g.column.name if isinstance(column, Column) else column— the class-qualified ORM-mapped attribute path works through that attribute. - Escape/validate the interpolated pieces (backticks for identifiers, enum-check op_type, int() the knobs).
- Replace print()-swallow with raised/propagated errors (shared with the fulltext fix per [Bug]: fulltext create_index swallows server errors with print() #31382).
- Regression: parametrized over (str, Table-column, ORM-attribute) asserting
create_sql("docs")always containsON docs(body).
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 vector index builders turn Column objects into "Doc.id" strings in DDL. 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
结论
测试不通过。列对象的名称映射已改善,但原 issue 要求的向量索引数值参数校验仍缺失,非法参数会直接进入生成的 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。docs(v),IVF 的三种列引用均可实际创建和删除索引,底表仍有两行;HNSW 的三种引用已检查生成 DDL,但本机实际 HNSW 创建报错,原因尚未确定,不把它算作该问题的产品失败。IVFVectorIndex('idx_check','v',lists='not-a-number').create_sql('docs')未拒绝非法数字,生成的 SQL 含lists = not-a-number;原 issue 明确要求检查数值参数。SDK 当前 DDL 渲染位置 直接插入该值。此处没有执行该无效 DDL,也不声称数据已损坏。待解决点
fix(python-sdk): unify SQL, transaction and driver boundaries (#31889)
XuPeng-SH commentedon Oct 30, 2026
新修复转 QA:#31889 已合入 main,合并提交
91dfab2132c4c4fcd3f9a115dbfa968b196b8b14。共享向量索引owner校验lists/m/ef_construction/ef_search(含后续赋值),非法数字在setup/DDL前拒绝;create/drop共享引用与异常传播路径。
已核对 issue 正文、完整评论及当前合并源码/测试内容。历史失败按其原 SHA 保留;新修复直接覆盖上述残留,未发现适用于新修复的已验证反例或尚未完成的开发 follow-up。本轮仅源码/测试内容静态核对,没有运行 MatrixOne 服务或 SDK 回归;作者在 PR 内的运行结果是作者证据,不是本轮独立测试。转 Ariznawlll 继续验证,不代表验收通过。
QA 待验范围:str/Table列/ORM属性,IVF及HNSW真实create/drop、非法数字/范围/修改后拒绝且无DDL、标识符/schema_translate_map;历史HNSW未归因错误需QA复核而非算通过。
Ariznawlll commentedon Oct 31, 2026
结论
测试通过。
关键证据
main@4f894474ad10e1b9dc338868145a118a71c1fa23,修复 fix(python-sdk): unify SQL, transaction and driver boundaries #31889 在祖先链;本次 HNSW 使用 CPU 路径,不涉及 GPU。qa_bad索引。删除不存在的索引会传播数据库错误,源行与连接池保持正常,各 3/3。schema_translate_map将逻辑 schema 映射到测试库后成功创建并删除 IVF;补充的 vector DDL 模拟驱动合同重复三轮共 180 passed,覆盖更多标识符和映射边界。issue_31400_vector_index_columns.py(提交bb8aa94a);该 PR 尚未合入,完整 suite 未运行。待解决点