Repository navigation
Description
Description
Parquet export labels BINARY and VARBINARY bytes as a UTF-8 string instead of unannotated binary. A legal binary value containing 0xFF makes the exported file unreadable by PyArrow even though SELECT ... INTO OUTFILE / MODUMP QUERY_RESULT report success. BLOB from the same row is correctly exported as binary.
Environment
- Branch:
main - Commit:
f847803802289b2b2d0df4f0a2f842c2804b823a(git_version() = f847803802) - Deployment: isolated local standalone, one CN, MySQL port 49301, 2026-10-28. PyArrow 24.0.0 and PyMySQL 1.4.6 used only to validate exported bytes/readback. Synthetic data only.
Steps to reproduce
The output paths must be writable by the MO service and readable by the verification client.
CREATE DATABASE pq_binary_repro;
USE pq_binary_repro;
CREATE TABLE t(id INT PRIMARY KEY, b BINARY(4), v VARBINARY(4), x BLOB);
INSERT INTO t VALUES (1, X'78FF79', X'78FF79', X'78FF79');
SELECT HEX(b),HEX(v),HEX(x) FROM t;
-- 78FF7900, 78FF79, 78FF79
SELECT id,b,v FROM t INTO OUTFILE '/tmp/pq_binary_repro.parquet' FORMAT 'parquet';
SELECT id,x FROM t INTO OUTFILE '/tmp/pq_blob_control.parquet' FORMAT 'parquet';import pyarrow.parquet as pq
print(pq.read_schema('/tmp/pq_binary_repro.parquet'))
print(pq.read_table('/tmp/pq_binary_repro.parquet').to_pylist())
print(pq.read_schema('/tmp/pq_blob_control.parquet'))
print(pq.read_table('/tmp/pq_blob_control.parquet').to_pylist())The same failure is reachable through the new MODUMP QUERY_RESULT Parquet route: enable save_query_result, run /* save_result */ SELECT id,v FROM t ORDER BY id, capture last_query_id(), then MODUMP QUERY_RESULT '<id>' INTO '/tmp/modump_binary.parquet' and read it with PyArrow.
Actual behavior
SELECT INTO OUTFILEandMODUMP QUERY_RESULTboth succeed.- Both Parquet schemas mark the
VARBINARYcolumn asv: string; theBINARYcolumn is likewiseb: string. pq.read_table(...)fails withUnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 1: invalid start byte.- Control:
BLOBisx: binaryand reads asb'x\xffy'; ASCII-onlyVARBINARYreads normally, showing that invalid UTF-8 bytes trigger the false string annotation. - MO's own
LOAD DATA INFILE ... FORMAT 'parquet'restoresHEX(v)=78FF79, so this is an interoperability/schema defect rather than a demonstrated MO-internal data-loss bug.
Expected behavior
BINARY/VARBINARY Parquet fields should be represented as binary byte arrays without the UTF-8 string logical annotation, preserving arbitrary bytes and remaining readable by standard Parquet clients. If a value cannot be exported in a chosen format, the export should fail rather than report success with a file that its declared schema cannot decode.
Stability and controls
- Reproducer: 3/3 independent fresh databases (
qmodfail_06,_07,_08) on the pinned SHA. Each run reproduced bothMODUMPand ordinarySELECT INTO OUTFILEwithVARBINARY X'78FF79'. - Control: the same runs successfully read ASCII-only
VARBINARYParquet; a separateBLOBcontrol read as real binary.MODUMP ... .jsonlrepresents the sameVARBINARYas{"$binary":"eP95"}. - Failure atomicity/data check: the exports reported success, so no SQL rollback occurred; source rows remained
HEX(v)=78FF79. MO Parquet LOAD restored the same bytes, while PyArrow failed at UTF-8 decoding.
Evidence
Saved local reproducer and exact output: /private/tmp/mo-explore-run-20261028/modump_failure_file.py (rounds 6–8) and /private/tmp/mo-explore-run-20261028/parquet_binary_schema.py (BINARY/BLOB control). The runnable SQL/PyArrow snippet above is the portable reproducer. Pinned-source evidence: buildParquetNode maps MySQL VARCHAR/VAR_STRING/STRING to parquet.String() without checking BINARY_FLAG, whereas the BLOB branch does; getValueFromVector supplies raw bytes for T_binary/T_varbinary.
Code analysis
Confirmed: the writer advertises a UTF-8 string logical type for the binary-family columns in the reproducer, then writes raw non-UTF-8 bytes. The buildParquetNode type switch above explains the contrast with the correctly typed BLOB control. The exact MySQL-type/flag mapping from MO's result metadata to this switch is an implementation detail to verify in the fix; the observed Parquet schema is direct evidence of the wrong output contract.
Regression coverage
Add Parquet export/readback tests for BINARY(4), VARBINARY(4) and BLOB containing 00, FF, padding and NULL, through both SELECT INTO OUTFILE and MODUMP QUERY_RESULT; verify with an independent Parquet reader and MO LOAD, not only row counts. Include an ASCII-only control and ensure the declared logical/physical schema matches the bytes.
Related
#30570added suffix-awareMODUMPParquet output, but this bug also affects the pre-existingSELECT INTO OUTFILEpath.#29845requests broader Arrow/Parquet conversion profiles for other extended types; this issue is a concrete malformed Parquet file for supportedBINARY/VARBINARYexport, not an unsupported conversion request.#30635concerns JSONLINE binary round-trip and is a separate format/path.
Activity
XuPeng-SH commentedon Oct 28, 2026
QA status for merged main
f73b4e93aafd0ec75b4766b03777811233a1f0c6(#31100): the merged change explicitly addresses binary-flagged Parquet columns using unannotated BYTE_ARRAY and includes serialized-footer/library-reader tests, according to the PR. Those are author-reported results, not independently executed in this environment.Resource headroom under the existing guard is insufficient here for the affected frontend test link or a current-head service. The original BINARY/VARBINARY
FFcases through both OUTFILE and MODUMP, independent PyArrow schema/byte readback, MO LOAD, NULL/padding and BLOB/ASCII controls remain unverified locally. Handing off to QA for acceptance.Ariznawlll commentedon Oct 28, 2026
结论
测试不通过。普通
SELECT INTO OUTFILE的 binary schema 和回读已修复;但MODUMP QUERY_RESULT对合法 ASCII 的VARBINARY仍成功导出为 Parquetstring,不符合本 issue 要求的未标 UTF-8 的binary类型。非 UTF-8 数据现已报错且未生成文件,不再复现原来的成功生成不可读文件。关键证据
f73b4e93aafd0ec75b4766b03777811233a1f0c6在测试时官方 main9e29011e7313a57962adc00963baa659d1e81e37的祖先链;实际服务git_version()为9e29011e73。fix(outfile): accept FIELDS ESCAPED BY/LINES STARTING BY and reject non-UTF-8 Parquet exports (#30710) #31100 主要修复 OUTFILE,未明确声称覆盖本 issue 的 MODUMP 整条路径。78FF79、610062、NULL,3/3 得到binaryschema 和正确字节;MOLOAD DATA ... format='parquet'回读 3/3,分别得到定长填充78FF7900、变长78FF79和对应 NULL。MOTR Dev/api updates #287 中普通 OUTFILE + 回读回归定向 3/3,最新 PR 的离线 CI 检查通过。save_query_result/last_query_id()/MODUMP QUERY_RESULT路径,VARBINARY 行X'76616C6964'加 NULL,导出成功但独立 PyArrow 3/3 读到 schemav: string,值为 Python 字符串'valid'而不是binary/b'valid'。每轮使用独立临时库和文件并清理。X'78FF79'3/3 返回 20301invalid UTF-8 value for VARBINARY,目标文件不存在且源数据不变;这符合 issue 的失败原子性兜底,但仍不能证明 MODUMP 的 binary schema 已修复。上述失败没有被写成 MOTR 成功 golden。待解决点
请核对 MODUMP 保存及重建结果元数据时的 binary 类型/flag 保留,补齐合法 ASCII 和任意字节的 Parquet binary schema 与独立客户端回读;普通 OUTFILE 回归已单独覆盖,完整 MOTR suite 和完整产品 CI 未运行。