Repository navigation
Description
Description
CREATE INDEX ... USING IVFFLAT ... INCLUDE(enum_column) is accepted by DDL validation but fails while populating the hidden entries table. The IVFFLAT plugin advertises ENUM as a supported INCLUDE type, so this prevents a documented/supported index shape from being created.
Environment
- Branch:
main - Commit:
01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90 - Deployment: local
mo-service, 2 CN / 1 TN / 1 Log service - Date: 2026-09-16
Steps to reproduce
create database ivf_enum_repro;
use ivf_enum_repro;
create table t (
id bigint primary key,
e enum('cold','hot'),
v vecf32(2)
);
insert into t values
(1,'cold','[1,0]'),
(2,'hot','[2,0]');
create index ix using ivfflat on t(v)
op_type 'vector_l2_ops' lists=1 include(e);Actual behavior
The index build fails:
ERROR 20203 (HY000): invalid argument operator cast, bad value [VARCHAR ENUM]
No ix metadata row or hidden index table remains after the rejected DDL, and the two base-table rows remain unchanged.
Expected behavior
The index should be created and preserve the ENUM member metadata so INCLUDE filtering and projection use the same labels and ordinals as the source column. If ENUM is intentionally unsupported, DDL validation must reject it before creating/building hidden objects rather than advertising it as supported and failing inside the build.
Stability and controls
- Reproducer: 3/3 on CN1 and 3/3 on CN2 with the same
VARCHAR ENUMcast error. - Control: an IVFFLAT index on the same vector column with
INCLUDE(json_col, uuid_col, binary_col, varbinary_col, text_col)builds successfully and returns the expected indexed rows. - SET control:
INCLUDE(set_col)builds and matches the full-scan filter/projection result. - Failure atomicity: base row count stays at 2; matching
mo_indexesrows and hidden tables both remain 0.
Evidence
Minimal SQL and the extended type matrix are retained in evidence/ivfflat_include_exotic.sql in the local validation worktree.
Code analysis
pkg/vectorindex/ivfflat/plugin/runtime/runtime.go includes types.T_enum in SupportedIncludeColumnTypes(). During hidden entries-table construction, pkg/vectorindex/ivfflat/plugin/plan/schema.go copies only Id, Width, and Scale from each INCLUDE column and drops plan.Type.Enumvalues. The hidden ENUM column therefore loses its member list, and the synchronous population query in pkg/vectorindex/ivfflat/plugin/compile/compile.go fails when assigning the source ENUM value to that incomplete target type.
Regression coverage
Add an IVFFLAT INCLUDE lifecycle case for ENUM covering initial build, label and ordinal predicates, projection, INSERT/UPDATE/DELETE maintenance, rollback, ALTER ... REINDEX, and multi-CN reads. Assert that failed DDL leaves no catalog or hidden-table residue.
Related
- Source exploration: [Bug]: v4.2.1 multi-CN IVF post search returns nondeterministic candidates due to unordered LIMIT merge #28943
- [Bug]: binary prepared ENUM/YEAR covering-index queries fail with unsupported type #26873 concerned binary prepared reads through regular covering indexes; it did not cover IVFFLAT INCLUDE metadata or index creation.
Activity
[-][Bug]: IVFFLAT INCLUDE on ENUM fails index build after dropping member metadata[/-][+][Bug]: IVFFLAT drops ENUM member metadata for hidden PK and INCLUDE columns[/+]Ariznawlll commentedon Sep 16, 2026
补充确认相同 schema 生成缺陷也影响源表主键,不需要 INCLUDE 即可触发。
当前 commit 在两台 CN 均报:
稳定性与原子性:基表仍为 2 行,
mo_indexes中该索引为 0 行,且没有隐藏表残留。对应源码是 entries 隐藏表的
origin_pk也只复制Id/Width/Scale,同样遗漏Enumvalues;所以 #28994 的准确影响面是 ENUM 主键或 ENUM INCLUDE 列。我已据此把标题从仅 INCLUDE 调整为 hidden PK/INCLUDE metadata,根因和修复点仍是同一个,不另开单。Ariznawlll commentedon Sep 16, 2026
补充异步 IVFFLAT 路径的影响。根因仍是本 issue 描述的隐藏列丢失
Enumvalues,不另开单。在相同 commit
01d60e1c4ded1b0f3fc1a4ecd75ce54e95e23b90上:异步 DDL 返回成功,但隐藏 entries 列被创建成:
后续结果:
0/12;SHOW FULL COLUMNS可见ENUM(0);SHOW CREATE TABLE <entries>因生成的 ENUM 定义不完整而直接报 SQL parser error;ASYNC后仍是原 issue 的同步错误:invalid argument operator cast, bad value [VARCHAR ENUM];所以 #28994 需要同时覆盖两种用户可见行为:
ENUM(0)隐藏列,索引维护不前进。建议回归中增加异步 DDL 成功后的目录定义、
SHOW CREATE TABLE、初始 replay 与 DML 维护断言,避免只验证同步报错路径。Fix IVFFLAT membership metadata and retry filtering (#29835)
Ariznawlll commentedon Oct 12, 2026
测试版本
main;commit:02a2823c2007d5e4fb4ada148e93743df337551a;日期:2026-10-12。原问题验证
按原 issue 建
ENUM('cold','hot')INCLUDE 列的 IVFFLAT,建索引成功;又建 ENUM 主键表并创建不带 INCLUDE 的 IVFFLAT,也成功。两表在 FORCE、PRE、POST、AUTO、INCLUDE 模式下各 3 轮均能正确读到'cold',未再出现VARCHAR ENUMcast 错误。Happy Path 覆盖
同步索引创建、ENUM 主键和 ENUM INCLUDE 两种隐藏列路径均通过;查询投影返回原成员名称,未变为空值或错误 ordinal。
Unhappy Path 覆盖
非匹配成员
'hot'仍存在于两张源表,WHERE e='cold'只返回目标行,排除建索引后错误扩大匹配。本轮未测异步 CDC 维护、事务回滚或 DROP/CREATE 失败残留,不将同步创建成功扩大为这些生命周期场景全部通过。白盒验证
同时验证隐藏 entries 的
origin_pk和 INCLUDE ENUM 两条元数据传播路径,避免只测其中之一。未做多 CN 读一致性。回归测试
已加入 MOTR PR #229 的两种 ENUM 建索引与五模式查询,compare 3/3。类型元数据缺陷不需要 big-data;异步、更新/删除和回滚建议由现有 IVFFLAT 生命周期测试另行补足,故本次不以这些未测路径作为关闭条件。
测试证据
测试结论
测试通过。
Ariznawlll commentedon Oct 16, 2026
测试版本
main48dbe277b6d20216c1c513d03c5cbd681380a8a2(执行前后核对origin/main;修复 PR #29835 已 MERGED,合入提交5cc681623bb0ca821d4422bc145c9e4ccf365fa1已进入该 main)原问题验证
此前已在 本 issue 的同步验收评论 确认同步 ENUM 主键与 INCLUDE 索引构建成功,但该评论明确未覆盖异步路径。本轮补测 issue 中原始 12 行
status ENUM('red','green','blue')+INCLUDE(status) ASYNC:CREATE INDEX成功;隐藏 entries 列为完整enum('red','green','blue'),不再是ENUM(0);SHOW CREATE TABLE可以解析;初始 entries 在约 20 秒内从 0 追平至 12/12,成员计数red/green/blue=4/4/4,与源表一致。Happy Path 覆盖
UPDATE id=1的 ENUM 状态、INSERT id=13和DELETE id=2;entries 最终仍为 12 行,red/green/blue=5/3/4,旧id=2条目为 0、新id=13条目为 1。第二台 CN 读取源表和隐藏 entries,得到相同计数与标签/序号。enum('cold','hot','warm')与enum('warm','cold','hot');SHOW CREATE TABLE正常;初始 replay 的主键/INCLUDE 序号精确为(1,3),(2,2)。该完整场景重复 3/3。Unhappy Path 覆盖
NULL、将 ENUM 主键cold更新为warm,再插入新的cold;活动版本 entries 精确为(1,2),(2,NULL),(3,1)(断言中NULL使用独立哨兵-1),未混淆成员序号或旧主键。随后删除hot,entries 精确变为(1,2),(3,1),与源表一致;3/3。白盒验证
origin_pk与 INCLUDE 列两套 ENUM 元数据,以及异步初始构建和后续 CDC replay;MatrixOne main 已有对应的异步 IVFFLAT 生命周期 BVT 源码。本轮未执行完整 BVT 或-race,不将源码存在视为 CI 已通过。回归测试
./motr 14_issue_regression.issue_28994_async_enum --repeat 3 -j 1:3/3 成功、3/3 场景语句成功,约 119 秒;Python 语法检查通过。PR (AOE) incompatible bug fix #237 尚未合入,完整 suite/集成 CI 尚未验证,后续继续跟踪。测试证据
success,无失败与跳过。enum('red','green','blue'),初始12/12与4/4/4,DML 后12/12与5/3/4;两台 CN 读数一致,测试库已删除。测试结论
测试通过。