Repository navigation
fix(frontend): preserve bytes and binary types in saved query results - #32269
Conversation
Saving a frontend result set through convertRowsIntoBatch rendered every
non-string VARCHAR/TEXT cell with fmt.Sprintf("%v", ...). Engine-extracted
[]byte cells - the presentation DATA BRANCH DIFF produces for VARCHAR and
VARBINARY columns - therefore became textual numeric lists such as
'[228 184 173 230 150 135]'. mysqlColDef2PlanResultColDef also mapped every
VAR_STRING column to VARCHAR, so VARBINARY diff columns lost their binary
logical type in the saved metadata. RESULT_SCAN returned the corrupted
values and INSERT ... SELECT persisted them.
- convertRowsIntoBatch now renders VARCHAR/TEXT/VARBINARY cells with
textRowValueBytes, which keeps the exact bytes for string/[]byte cells,
uses the client-visible presentation (types.ArrayToString /
BlockScaledToString) for vector cells, and leaves other scalars on their
existing fmt.Sprintf rendering, so existing consumers are unchanged.
- mysqlColDef2PlanResultColDef maps VAR_STRING/VARCHAR columns carrying
the binary protocol charset to T_varbinary, and convertRowsIntoBatch
gained a T_varbinary case, so binary columns keep raw bytes and binary
metadata.
Proof:
- Test_convertRowsIntoBatchVarStringBytesAndBinaryType and
Test_convertRowsIntoBatchVectorTextPresentation fail on the parent base
(saved '[228 184 173 230 150 135]' bytes, varbinary column typed 61) and
pass after the fix; the existing conversion/decimal/error/unsigned and
result-save metadata tests all still pass, and go vet is clean.
- On a standalone instance built from this tree the issue's exact
reproduction returns v='中文', HEX(bin)='FF000A' from result_scan and the
INSERT ... SELECT copy persists those values; a VECF32 diff control reads
back '[3, 4]' identical to the direct output.
- New BVT diff_saved_text_binary (sql + checked result) passes 100% under
mo-tester.
Related to matrixorigin#31535
The CI changed-code coverage gate measured the textRowValueBytes helper at 70% (14/20 changed blocks): the []types.BF16, []types.Float16, []int8 and types.BlockScaledValue branches had no coverage. Add Test_convertRowsIntoBatchBlockScaledAndNarrowVectorText: BF16/Float16/ int8 vector cells and a vecf8 block-scaled cell must save the same display text the client-visible result presents (asserted with MysqlResultSet.GetString as the oracle), while an unparseable block-scaled cell keeps the pre-fix "%v" presentation (empty text, since BlockScaledValue's fmt.Stringer renders a corrupt cell as "") instead of failing the whole saved result.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 590331d468eeac3dabb110a3aea3d505dd19d878
Assessment: approve
The fix preserves saved text/binary bytes and binary metadata through the existing result-save path, and reuses the protocol's vector formatters. The changed conversion and public readback/copy contracts are covered without adding state or another persistence mechanism.
Model: gpt-6.1-sol / max
Session: 01a1a004-9884-72c0-ad39-f096c4209c4a · slot 1 · generation 0
Validation:
-
Reviewed all four changed files, the binary golden, both discussion entries and linked issues 31535/31534; traced branch extraction, protocol rendering, metadata, save and RESULT_SCAN consumers.
-
Local audit passed: clean frozen source, patch identity, gofmt for both Go files, binary-golden byte/metadata/copy oracles and discussion coverage. Receipt checks/1793919069942493664-2.json and audit.log retained.
-
Reused frozen exact-head successful build, UT/SCA/coverage and PROXY/PESSIMISTIC BVT checks. Author reports focused conversion red/green, regression/vet and 21/21 public BVT execution.
Limitations:
- No local CGo frontend tests or live SQL/BVT execution; raw CI/author runtime logs are not supplied. Unsupported JSON/BIT/BLOB saving remains the separately scoped issue 31534.
✅ Merged into
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #31535
What this PR does / why we need it:
Saving a frontend result set through
convertRowsIntoBatchrendered every non-string VARCHAR/TEXT cell with
fmt.Sprintf("%v", ...), soengine-extracted
[]bytecells — the presentationDATA BRANCH DIFFproducesfor VARCHAR and VARBINARY columns — became textual numeric lists such as
'[228 184 173 230 150 135]'. The same result-metadata conversion mapped everyVAR_STRINGcolumn to VARCHAR, so VARBINARY diff columns also lost theirbinary logical type in the saved result.
RESULT_SCANthen returned thecorrupted values and
INSERT ... SELECTpersisted the wrong data.Root cause
convertRowsIntoBatchtype-asserted VARCHAR/TEXT row values tostringandformatted anything else with
fmt.Sprintf("%v", ...); the diff pipeline(
data_branch_output.go->extractRowFromVector) hands over[]bytecells for VARCHAR/VARBINARY and
[]float32cells for VECF32 family columns.mysqlColDef2PlanResultColDefignored the column charset and mapped everyMYSQL_TYPE_VAR_STRING/MYSQL_TYPE_VARCHARresult column toT_varchar,including VARBINARY columns, which publish
VAR_STRINGwith the binaryprotocol charset.
Changes (all in
matrixorigin/matrixone)pkg/frontend/util.go:convertRowsIntoBatchrenders VARCHAR/TEXT/VARBINARYcells through the new
textRowValueByteshelper;string/[]bytecells keeptheir exact bytes, vector cells (
[]float32/[]float64/[]BF16/[]Float16/[]int8/BlockScaledValue) render with the same presentation theclient sees (
types.ArrayToString/types.BlockScaledToString), and otherscalars keep the existing
fmt.Sprintfrendering so current consumers areunchanged. NULL rows still produce NULL slots.
pkg/frontend/util.go:mysqlColDef2PlanResultColDefmaps VAR_STRING/VARCHARcolumns carrying the binary protocol charset to
T_varbinary(
MaxVarBinaryLen), andconvertRowsIntoBatchgained aT_varbinarycase, sobinary columns keep raw bytes and binary metadata in the saved result.
pkg/frontend/util_test.go: new focused UTs.test/distributed/cases/git4data/branch/diff/diff_saved_text_binary.sqland.result: new BVT for the issue's user-visible contract.Issue-to-test proof
Test_convertRowsIntoBatchVarStringBytesAndBinaryTypecovers multibyteVARCHAR bytes (
中文), raw VARBINARY bytesFF 00 0A, NULL vs empty,embedded NUL/non-UTF-8 counterexamples, and the saved binary column type
(65/T_varbinary). On the parent base it fails (saves
'[228 184 173 230 150 135]'bytes and types the binary column 61/T_varchar); after the fix itpasses — recorded red/green evidence for [Bug]: saved DATA BRANCH DIFF corrupts text and binary values returned by RESULT_SCAN #31535.
Test_convertRowsIntoBatchVectorTextPresentationcovers the issue-commentVECF32 case (saves
"[2, 2]"display text rather than the Go%vform[2 2]); red on base, green post-fix.Test_convertRowsIntoBatchBlockScaledAndNarrowVectorText(added after the CIchanged-code coverage gate flagged the helper's remaining branches) covers
BF16/Float16/int8 vector cells (display text such as
"[2, -0.5]"), ablock-scaled (vecf8) cell saved exactly as
MysqlResultSet.GetStringrenders it for the client, and an unparseable block-scaled cell that keeps
the pre-fix
%vpresentation (empty text: the fmt.Stringer path renders acorrupt cell as "") instead of failing the whole saved result.
this tree:
result_scan(@qid)returnsv='中文'andHEX(bin)='FF000A', andINSERT INTO copied SELECT ... FROM result_scan(@qid)persists those values;the source table is untouched; a VECF32 diff reads back
[3, 4], identical tothe direct output.
diff_saved_text_binary(direct diff,result_scanreadback,INSERT ... SELECT, NULL-filter and source-table checks) passes 100% underthe repo's mo-tester (21/21 statements). The generated
.resultwasinspected against the intended semantics before submission.
Test commands
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -v -run 'Test_convertRowsIntoBatchVar|Test_convertRowsIntoBatchVector' ./pkg/frontend/— both new tests fail.-run 'Test_saveQueryResultMeta|Test_mysqlColDef2PlanResultColDefIntegerSignedness|Test_convertRowsIntoBatch'also passes all existing conversion/decimal/error/unsigned round-trip and
result-save tests (
go testvia the CGo wrapper).go vet -mod=readonly ./pkg/frontend/with the documented CGo environment:clean.
gofmtclean on both changed Go files..agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -v -run 'Test_convertRowsIntoBatchBlockScaledAndNarrowVectorText' ./pkg/frontend/passes; with it, every changed block of
textRowValueBytesis exercised(the CI coverage job had measured 70%: 14/20 changed blocks, leaving the
BF16/Float16/int8/BlockScaledValue branches untested).
bash run.sh -p <...>/git4data/branch/diff -m run -r 100 -i diff_saved_text_binary— SUCCESS RATE 100%.Residual risk
hand-built frontend result sets default to charset 0 and UUID/T_Rowid/T_enum
VAR_STRING columns publish text charsets, so their saved types are unchanged
(covered by existing tests passing).
client-visible result presents; re-materializing a vector type requires an
explicit CAST.
unsupported-type save error, tracked separately in [Bug]: DATA BRANCH DIFF fails on JSON, BIT and BLOB when saving query results #31534.
pkg/frontendrun, whole distributed BVT) remain for CI;the focused red/green and regression runs above cover the changed conversion
path and its existing consumers.
Related to #31535