You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: MODUMP QUERY_RESULT exports BIT as decimal text, causing wrong values after LOAD DATA round-trip #30653
CREATEDATABASEmodump_bit_repro;
USE modump_bit_repro;
CREATETABLEsrc(id INTPRIMARY KEY, b BIT(8));
INSERT INTO src VALUES(1,1);
CREATETABLEdstLIKE src;
SET save_query_result=on;
/* save_result */SELECT id,b FROM src;
SELECT last_query_id();
把上一步返回的 query ID 填入以下语句:
MODUMP QUERY_RESULT '<query ID>'
INTO '/tmp/modump_bit_repro.csv' HEADER 'false';
LOAD DATA INFILE '/tmp/modump_bit_repro.csv'
INTO TABLE dst FIELDS TERMINATED BY ',';
SELECT id,CAST(b AS UNSIGNED) FROM src;
-- 1, 1SELECT id,CAST(b AS UNSIGNED) FROM dst;
-- 1, 49:导出、导入均成功,但值改变
正常对照:
CREATETABLEcontrolLIKE src;
SELECT*FROM src INTO OUTFILE '/tmp/modump_bit_control.csv' HEADER 'false';
LOAD DATA INFILE '/tmp/modump_bit_control.csv'
INTO TABLE control FIELDS TERMINATED BY ',';
SELECT id,CAST(b AS UNSIGNED) FROM control;
-- 1, 1:正确
[Comment submitted by the MOI dev/test agent, authorized by LW]
Follow-up on the remaining JSONLINE half of this issue (the CSV export half was fixed by #30655).
Root cause (jsonline representation)
Export side: result-set export to JSONLINE writes BIT as a JSON number ({"b":1,"id":1}) — a valid textual representation of the value.
Load side: jsonLineScalarText (sole definition in pkg/sql/colexec/external/reader_csv.go, shared by jsondata='object' and 'array') passes the JSON scalar's text through to BIT construction with the same byte-oriented semantics as the CSV LOAD T_bit branch (cf. pkg/sql/colexec/external/external.go:2025). So the text "1" is interpreted as byte 0x31 → 49, and "44"/"255" exceed the 1-byte width and error out — matching the 3/3 repro reported above.
The two file formats therefore disagree on representation: CSV now carries raw bytes (consistent after #30655), while JSONLINE carries a decimal number that LOAD still interprets as raw bytes.
Suggested minimal fix (load side only)
Give BIT columns numeric semantics in the jsonline scalar → column-value conversion:
case types.T_bit:
v, err:=strconv.ParseUint(strings.TrimSpace(s), 10, 64)
iferr!=nil||v>=1<<colWidth { /* invalid / out-of-range for BIT(width) */ }
b:=types.EncodeUint64(&v)[:byteWidth]
slices.Reverse(b) // big-endian raw bytes, mirroring the post-#30655 export encoding
Both requested representations then round-trip correctly without touching the exporter or the CSV byte path:
(An alternative — exporting BIT as {"$binary":"<base64 raw bytes>"} like #30663 does for the binary family — is byte-safe for embedded zeros but changes on-disk compatibility and needs both export and load changes; the numeric-semantics fix above is the smaller change for what is reported here.)
Regression plan (red → green)
BIT(8) rows {NULL, b'1', b'0101100' (=44), b'11111111' (=255)} exported via INTO OUTFILE ... FORMAT 'jsonline' and loaded back via LOAD DATA ... FORMAT='jsonline': currently red (1→49; 44/255 width error); after the fix all rows should round-trip identically.
Same corpus with jsondata='array' (shared scalar path).
MODUMP QUERY_RESULT jsonline variant of the original repro, end to end.
Status
I searched open/upstream PRs: none currently covers this JSONLINE half. This run's environment port lacks a git branch/commit push channel (no bound workspace executor), so the patch has not been landed, compiled, or independently reviewed — the above is analysis and design derived from current main code plus the 3/3 repro in this thread, posted here so the fix can pick it up directly. The next run with a write channel will follow the standing flow: fork branch → failing regression test first → patch → gates (UT + independent review) → PR onto dev, CC @XuPeng-SH and the assignee @slyunnn.
Regression and extended verification for #30653 (2026-10-22)
Verification Environment
Freshly fetched MatrixOne origin/main: 9f7fe43649b3eb9e34f1bc4073ecbc03c6e2a2a3 — frontend: fix result save/scan chain issues (#30552 #30553 #30571) (#30641). Source HEAD matches; rebuilt/restarted binary reports 9f7fe43649, Go 1.27.1, Linux/arm64.
Complete local logical topology: 2 CN / 1 TN / 1 Log service / Proxy, co-located in one container.
Proxy 127.0.0.1:6001, CN1 127.0.0.1:16001, and CN2 127.0.0.1:16002 were healthy. Original MODUMP CSV, extended CSV, JSONLINE object/array and exported-file import checks actually executed through all three endpoints.
Clients: PyMySQL and Go database/sql / go-sql-driver/mysql, with interpolateParams=false. Tests used text COM_QUERY, retained /* save_result */, and performed real server-side and LOCAL file transfers; no binary-prepared-statement claim.
What Was Covered
OK — Exact original saved-result MODUMP CSV scenario: BIT(8)=1 exports as raw byte 0x01 and restores as 1, not 49, at all three endpoints.
OK — MODUMP and ordinary CSV OUTFILE checked against an independent big-endian byte oracle for 10 widths: 1, 7, 8, 9, 15, 16, 31, 32, 63, 64. Each corpus includes zero, one, width maximum and NULL.
OK — Per endpoint, the committed protocol case checks 20 exact file-byte oracles and 40 server/LOCAL roundtrips, including BIT(64) maximum 18446744073709551615. All CSV checks passed.
OK — JSONLINE ordinary OUTFILE and the supported result_scan(...) AS r → INTO OUTFILE ... FORMAT 'jsonline' route preserve numeric/NULL JSON output across BIT(1), BIT(8), and BIT(64): 18/18 export checks.
Failed — JSONLINE numeric imports still use byte semantics in both object and array modes. Valid BIT(8) value 1 successfully imports as 49; 44 / 255 encounter width errors, and the BIT(64) maximum returns 20101 with len(val)=20.
Failed — The single-value JSONLINE matrix contains 78 failing valid-number checks across the three endpoints. Its 18 NULL controls pass.
Failed — Actual JSONLINE exported-file roundtrips fail in all 18 width/path/endpoint combinations; the tested files return 20101 and leave zero rows. Source values remain unchanged.
OK — Out-of-range numeric controls for object/array and BIT(1/8/64): 18/18 rejected, targets empty, connections healthy.
OK — Both official CSV fix regression groups and the complete frontend package passed with -count=1.
Not covered — Direct MODUMP QUERY_RESULT ... FORMAT 'jsonline' is unsupported by current grammar and returns 1064 on all three endpoints. The saved-result JSONLINE export check above is an alternative route, not a claim that this MODUMP syntax works.
The CSV half is fixed by PR #30655, commit 774d0eda08c622e8717bed8caa8cd8c2ae3ffc2a — fix(frontend): preserve raw BIT bytes in MODUMP query results (#30655), included in the tested main revision.
The specified follow-up comment describes the remaining JSONLINE problem, not a delivered fix. Actual execution confirms it remains unresolved: JSON numbers are exported correctly, but the shared scalar-import path still feeds decimal text into raw-byte BIT construction. An additional JSONLINE import-side fix is needed while retaining CSV raw-byte semantics.
These are product-result failures, not environment or runner failures. No MatrixOne production source was modified, and no wrong-value expectation was accepted.
MOTR / BVT Coverage
Branch: test/issue-30653-modump-bit-bytes.
Source commit: ee127a46535f160605af8636a72482ad5cc129fe — test: add MOTR regression for #30653; SSH push, remote SHA and tracking verified.
Added script/14_issue_regression/issue_30653_modump_bit_bytes_protocol.{go,sh}. Durable CI coverage is explicitly limited to the fixed CSV half; failing JSONLINE probes and their independent expected values were retained as verification evidence, not recorded as passing goldens.
The launcher uses the existing Go module and connection environment variables. Unique databases/stages and exact file cleanup permit parallel case scheduling; session save_query_result is restored. Saved-result cache entries follow normal server retention.
Recording passed. Final source replay alongside the existing compression control used -j 2 --repeat 2: 4/4 executions, 30/30 runner units.
Included in weekly MOTR PR #251, cherry-pick c9231ff5253b465a7da4e0b635577651e68415b9.
Hosted Actions run is budget-blocked before any steps ran; no hosted CI pass is claimed.
Final endpoint health, default session policy, database/stage cleanup and generated export-file cleanup checked.
Final Conclusion
Partially fixed: the original MODUMP CSV issue is fixed, but the JSONLINE half in the requested comment remains reproducible on current main. The issue should remain open pending that product fix.
Large-data regression: not needed. This is a per-value representation and width contract; small exact-value corpora and the 64-bit boundary reproduce it deterministically. Increasing row count would add CI cost without exercising a distinct failure boundary.
approve 评审 5909244887 对应较早 head 5b4aae1329572226815ebb2d588f11d699ec4cef,不是最终 head。评审报告独立 helper 62,001 值检查及 12 工件静态核对;其 native/service BVT 因 Go 版本限制未重跑,复用当时冻结 CI 与作者报告,未取得作者原始日志。合并队列记录 显示 CI Required success;不把旧 head 评审或作者结果冒称本轮最终版本实测。
Activity
MatrixAdventurer commentedon Oct 20, 2026
由 LW 授权的 ChatGPT Personal 智能体提交。
修复 PR 已提交:#30655(目标 main;上游没有 dev,按用户授权使用 main)。
固定 head:8b23b474564c7b2d700e2fca46160ee5fcd69e31;基线:743e749a1e33d6c845bb73999e8c82d297a2b657。最终3文件,+171/-2,共173行,含回归测试。
实际红/绿验证:
操作记录:上述智能体核实MatrixAdventurer本人fork/上游关系和写权限,创建候选commit、verify/modump-bit-30653验证分支及fix/modump-bit-bytes-30653修复分支。Issue与PR均已添加指派XuPeng-SH,PR审阅请求包含XuPeng-SH,已通过GitHub读取返回值再次确认;保留原Issue已有负责人matrix-meow。PR读回为3文件+171/-2、无冲突,完整上游CI正在运行。没有推送上游、合并、部署或关闭Issue。完整命令、固定提交和证据见PR正文。
Ariznawlll commentedon Oct 21, 2026
同根输出格式错配还影响另一条结果导出路径:
SELECT ... INTO OUTFILE ... FORMAT 'jsonline'将BIT(8)作为十进制 JSON 数字写出,但 JSONLINELOAD DATA仍按字段原始字节构造 BIT。3 个全新数据库中,源BIT(8)=1导出为{"b":1,"id":1},单行回导成功却得到BIT(8)=49(3/3);含1/44/255/NULL的文件回导在44处报宽度错误,目标表保持空(3/3)。精确 SQL/输出:/private/tmp/mo-sequence-run2-20261020/ten-bugs-1021/jsonline-bit-repeat.jsonl。这与本 issue 的 MODUMP CSV 路径一样,是十进制文本表达与 BIT LOAD 原始字节语义不匹配;不再单独提 bug。另发现普通 CSV OUTFILE 的 BIT 字节若恰好是分隔符,未加引号时会静默回导成 0;该边界已补到 #30702,因为它属于 CSV 未转义分隔符的根因。修复/回归时请分别验证 JSONLINE 数字和 CSV 原始字节两种表示。
MatrixAdventurer commentedon Oct 21, 2026
由LW授权的MOI智能体提交。
@Ariznawlll 您在 #30655 中报告的三条 jsonline 复现(值 1 可载入但回读异常、值 44 报宽度错误且无部分载入、NULL 无法复现)已完成代码级静态复核,代码读取锚定 #30655 头节点
00f0b211308bde5a24de621e2c1c74a00b0a7d7e,结论:问题成立,且是与 CSV 不同的独立根因——jsonline 导入路径复用了 "T_bit 按原始字节逐字节解析" 的 CSV 语义,而 jsonline 导出侧把 BIT 写成十进制数字字面量,两种表示不兼容。CSV 原始字节语义不受影响,#30655 的既有回归仍然有效。依据:
pkg/frontend/export.govectorValueToJSON()L1364-L1366:case types.T_bit:→val := vector.GetFixedAtNoTypeCheck[uint64](vec, i)→ 返回uint64,经json.Marshal输出十进制数字。因此BIT(8)的 1 / 44 在 jsonline 中写为数字字面量1/44。pkg/sql/colexec/external/external.go:getColData()(L1931 起,case types.T_bit:L2026 起)对T_bit执行if len(field.Val) > 8 → data too long,随后val = (val << 8) | uint64(field.Val[i])逐字节累加;isLegalLine()(L1053 起,L1084 起)同语义做严格预检,val > (1<<width)-1判非法。L1952-L1955 注释明确写着 "T_bit carries raw bytes (parsed byte-by-byte, not as text)"——该语义对导出原始字节的 CSV 是正确的,但对 jsonline 的数字 token 是错的。1(单字节0x31)→ 按原始字节解释 → 回读 49;44为 2 字节0x34 0x34→ 逐字节值0x3434=13364 > 255→ 宽度错误拒绝行、目标表为空(与"无部分载入"一致);null→field.IsNull→ 正常回读 NULL,因此不构成复现(您的观察正确)。9 之外的单字节数字以外的值因 token ≥2 字节全部会报宽度错误;09 能载入但回读为对应 ASCII 码 48~57(如 9→57),与 1→49 同构。修复方向(后续单独补丁将实施并引用本评论):
T_bit分支:当目标列为T_bit且字段为非引号 JSON 数字 token 时,按十进制解析为uint64,再按列宽以大端字节序编码写入;CSV 原始字节路径保持不变。导出侧不改动——十进制数字是合法 JSON 且与现有文件兼容。本轮状态: 当前执行环境不具备代码推送通道(沙箱无法 push 到 fork),本轮仅完成定位与方案登记;补丁交付时将附回归证据并请求复核。CSV 修复与 #30655 的 CI 状态不受影响。
MatrixAdventurer commentedon Oct 21, 2026
[Comment submitted by the MOI dev/test agent, authorized by LW]
Follow-up on the remaining JSONLINE half of this issue (the CSV export half was fixed by #30655).
Root cause (jsonline representation)
{"b":1,"id":1}) — a valid textual representation of the value.jsonLineScalarText(sole definition inpkg/sql/colexec/external/reader_csv.go, shared byjsondata='object'and'array') passes the JSON scalar's text through to BIT construction with the same byte-oriented semantics as the CSV LOADT_bitbranch (cf.pkg/sql/colexec/external/external.go:2025). So the text"1"is interpreted as byte0x31→ 49, and"44"/"255"exceed the 1-byte width and error out — matching the 3/3 repro reported above.The two file formats therefore disagree on representation: CSV now carries raw bytes (consistent after #30655), while JSONLINE carries a decimal number that LOAD still interprets as raw bytes.
Suggested minimal fix (load side only)
Give BIT columns numeric semantics in the jsonline scalar → column-value conversion:
Both requested representations then round-trip correctly without touching the exporter or the CSV byte path:
1→ BIT(8)0x010x01→ BIT(8)0x01(existing behavior, already covered by fix(frontend): preserve raw BIT bytes in MODUMP query results #30655)(An alternative — exporting BIT as
{"$binary":"<base64 raw bytes>"}like #30663 does for the binary family — is byte-safe for embedded zeros but changes on-disk compatibility and needs both export and load changes; the numeric-semantics fix above is the smaller change for what is reported here.)Regression plan (red → green)
INTO OUTFILE ... FORMAT 'jsonline'and loaded back viaLOAD DATA ... FORMAT='jsonline': currently red (1→49; 44/255 width error); after the fix all rows should round-trip identically.jsondata='array'(shared scalar path).MODUMP QUERY_RESULTjsonline variant of the original repro, end to end.Status
I searched open/upstream PRs: none currently covers this JSONLINE half. This run's environment port lacks a git branch/commit push channel (no bound workspace executor), so the patch has not been landed, compiled, or independently reviewed — the above is analysis and design derived from current
maincode plus the 3/3 repro in this thread, posted here so the fix can pick it up directly. The next run with a write channel will follow the standing flow: fork branch → failing regression test first → patch → gates (UT + independent review) → PR ontodev, CC @XuPeng-SH and the assignee @slyunnn.slyunnn commentedon Oct 22, 2026
Regression and extended verification for #30653 (2026-10-22)
Verification Environment
origin/main:9f7fe43649b3eb9e34f1bc4073ecbc03c6e2a2a3—frontend: fix result save/scan chain issues (#30552 #30553 #30571) (#30641). SourceHEADmatches; rebuilt/restarted binary reports9f7fe43649, Go1.27.1, Linux/arm64.2 CN / 1 TN / 1 Log service / Proxy, co-located in one container.127.0.0.1:6001, CN1127.0.0.1:16001, and CN2127.0.0.1:16002were healthy. Original MODUMP CSV, extended CSV, JSONLINE object/array and exported-file import checks actually executed through all three endpoints.database/sql/go-sql-driver/mysql, withinterpolateParams=false. Tests used textCOM_QUERY, retained/* save_result */, and performed real server-side and LOCAL file transfers; no binary-prepared-statement claim.What Was Covered
BIT(8)=1exports as raw byte0x01and restores as1, not49, at all three endpoints.10widths:1,7,8,9,15,16,31,32,63,64. Each corpus includes zero, one, width maximum and NULL.20exact file-byte oracles and40server/LOCAL roundtrips, includingBIT(64)maximum18446744073709551615. All CSV checks passed.result_scan(...) AS r → INTO OUTFILE ... FORMAT 'jsonline'route preserve numeric/NULL JSON output acrossBIT(1),BIT(8), andBIT(64):18/18export checks.BIT(8)value1successfully imports as49;44/255encounter width errors, and theBIT(64)maximum returns20101withlen(val)=20.78failing valid-number checks across the three endpoints. Its18NULL controls pass.18width/path/endpoint combinations; the tested files return20101and leave zero rows. Source values remain unchanged.BIT(1/8/64):18/18rejected, targets empty, connections healthy.-count=1.MODUMP QUERY_RESULT ... FORMAT 'jsonline'is unsupported by current grammar and returns1064on all three endpoints. The saved-result JSONLINE export check above is an alternative route, not a claim that this MODUMP syntax works.44was checked as an encoding value, not claimed as a delimiter-safe roundtrip.Findings
The CSV half is fixed by PR #30655, commit
774d0eda08c622e8717bed8caa8cd8c2ae3ffc2a—fix(frontend): preserve raw BIT bytes in MODUMP query results (#30655), included in the tested main revision.The specified follow-up comment describes the remaining JSONLINE problem, not a delivered fix. Actual execution confirms it remains unresolved: JSON numbers are exported correctly, but the shared scalar-import path still feeds decimal text into raw-byte BIT construction. An additional JSONLINE import-side fix is needed while retaining CSV raw-byte semantics.
These are product-result failures, not environment or runner failures. No MatrixOne production source was modified, and no wrong-value expectation was accepted.
MOTR / BVT Coverage
test/issue-30653-modump-bit-bytes.ee127a46535f160605af8636a72482ad5cc129fe—test: add MOTR regression for #30653; SSH push, remote SHA and tracking verified.script/14_issue_regression/issue_30653_modump_bit_bytes_protocol.{go,sh}. Durable CI coverage is explicitly limited to the fixed CSV half; failing JSONLINE probes and their independent expected values were retained as verification evidence, not recorded as passing goldens.save_query_resultis restored. Saved-result cache entries follow normal server retention.-j 2 --repeat 2:4/4executions,30/30runner units.c9231ff5253b465a7da4e0b635577651e68415b9.-j 4 --repeat 2,20/22executions passed; both failures are the separately recorded [Performance]: IVFFLAT PRE hybrid queries execute the same MATCH search twice #30165 protocol case. The new CSV case passed both rounds. Runner concurrency is not MatrixOne engine-parallel evidence.Final Conclusion
Partially fixed: the original MODUMP CSV issue is fixed, but the JSONLINE half in the requested comment remains reproducible on current main. The issue should remain open pending that product fix.Large-data regression: not needed. This is a per-value representation and width contract; small exact-value corpora and the
64-bit boundary reproduce it deterministically. Increasing row count would add CI cost without exercising a distinct failure boundary.fix: preserve BIT values when loading JSONLINE (#32759)
XuPeng-SH commentedon Nov 15, 2026
QA 交接(待验证,不是验收通过)
#32759 已于 2026-11-15 06:26:33 UTC 合入 main,merge SHA
c71e0c6904f444f45c4f4095be0e9f088b0c3b50,最终 PR head692be578521e3768170a8bef28892be2e828b34f。此前 #30655 已修复 MODUMP CSV 原始字节编码;本次补齐剩余 JSONLINE 数值导入:区分 object/array 的 JSON NUMBER 与字符串,在原始 NULLIF 判断之后将规范非负 uint64 转为 BIT 值,覆盖直接构造及 varchar 暂存后的 BIT cast。CSV、Kafka、带引号字符串、JSON null 和非规范数字的既有行为保留,导出器不变。已重读全部 5 条历史评论。2026-10-22 的 78 项数值失败及 18 项导出文件回导失败发生在旧 main
9f7fe43649b3,对应的 JSONLINE 开发 follow-up 现由已合并修复承接,不直接视为新版本反例。未发现适用于本次合并修复的已验证反例或其他未完成开发 follow-up;本单是产品正确性问题,非 CI flaky,保持 open 转 Ariznawlll 验证。证据与限制:
5b4aae1329572226815ebb2d588f11d699ec4cef,不是最终 head。评审报告独立 helper 62,001 值检查及 12 工件静态核对;其 native/service BVT 因 Go 版本限制未重跑,复用当时冻结 CI 与作者报告,未取得作者原始日志。合并队列记录 显示 CI Required success;不把旧 head 评审或作者结果冒称本轮最终版本实测。建议 QA 在包含本次 merge 的 main 重跑原始 CSV 对照、JSONLINE object/array、0/1/44/255/NULL、BIT(1/8/64)、2^53+1/UINT64_MAX、原始字段 NULLIF、字符串与越界拒绝、保存结果导出后跨 CN 回读及连接恢复。保存结果 JSONLINE 使用已支持的
result_scan(...) → INTO OUTFILE FORMAT 'jsonline';不宣称直接 MODUMP JSONLINE 语法可用。#30702 的通用 CSV 分隔符转义仍为独立范围;不因此新增 4.2 backport 要求。Ariznawlll commentedon Nov 16, 2026
测试版本
7fcd9bdff8433d72983f0399fd5c10dcab91a00a;fix(frontend): preserve raw BIT bytes in MODUMP query results #30655(merge commit774d0eda08)与 fix: preserve BIT values when loading JSONLINE #32759(merge commitc71e0c6904)均在该 main 祖先链。git_version() = 7fcd9bdff8。原问题验证
MODUMP QUERY_RESULT导出的 BIT(8)=1 文件字节为31 2c 01 0a,即1,<raw 0x01>\n,不再是会被 LOAD 解释为 49 的十进制字符。重新 LOAD 后CAST(b AS UNSIGNED)=1;普通 OUTFILE 对照组也保持为 1。result_scan -> INTO OUTFILE FORMAT jsonline -> LOAD DATA全链路保持精确值,未再发生浮点精度或 BIT 语义损坏。Happy Path 覆盖
2^53+1 = 9007199254740993与UINT64_MAX = 18446744073709551615精确恢复。Unhappy Path 覆盖
BIT(8) 的 JSON 输入 256 被拒绝,实测错误码 20101(data too long,type width = 8);目标表保持 0 行,连接仍可继续执行 SQL。
白盒验证
核对 #30655 的 MODUMP BIT 原始字节导出路径,以及 #32759 的 JSONLINE BIT 数值转换和加载路径;覆盖 CSV 与 JSONLINE 两个独立修复面,未修改产品源码。
回归测试
已追加 matrixorigin/motr#349:
14_issue_regression/issue_30653_modump_bit_roundtrip(35 语句)。录制后普通 diff 模式 3 并发连续两轮通过;PR 4 项 CI 全部成功。该用例标记@target-branch: main,未混入 4.2-dev。测试结论
测试通过。