Repository navigation
Conversation
53ecf84 to
0903902
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
The decimal round-trip fix looks useful, but the new generic DECIMAL metadata inference still has a real type-selection hole.
pkg/frontend/util.go now derives decimal precision as length - 2 in mysqlDecimalPrecisionFromColumn(). That only matches MatrixOne's own internal setColLength() convention, where DECIMAL length is encoded as width + 2 (pkg/defines/type.go). It is not a general rule for MySQL DECIMAL metadata.
For example, a signed DECIMAL(19,0) can be reported with display length 20, which this code would infer as precision 18. That downgrades the value from T_decimal128 to T_decimal64. If this path consumes real MySQL-compatible column metadata, 19-digit scale-0 decimals can be materialized into the wrong engine type and then overflow or misparse.
Please avoid reverse-engineering precision from Length() with a fixed offset, and add coverage for metadata that does not come from MO's own width + 2 producer path.
XuPeng-SH
left a comment
There was a problem hiding this comment.
I re-checked the latest head. The decimal fixes look useful, but there is still one remaining typed-value hole in the new tuple normalization path.
normalizeTupleColumnValue() was added so values coming back from the branch hashmap as raw []byte can be decoded back into fixed-width MatrixOne types before compare / format / append. But its fixed-width decode switch still omits types.T_year.
That leaves a real runtime gap:
YEARis otherwise treated as a supported typed value in the surrounding data-branch helpers (formatting / compare paths already havetypes.T_yearbranches)- the branch hashmap still uses the raw-byte/default path for fixed-width types it does not specially materialize
- so a
YEARvalue coming back through this new normalization path still falls into"unexpected byte slice for fixed-width column type"instead of being decoded
In other words, the decimal regression is fixed, but data branch diff can still break on tables containing YEAR columns because this new byte->typed normalization path is now the choke point.
Concrete suggestions
- Add
types.T_yearto the fixed-width decode switch innormalizeTupleColumnValue(). - Add one focused regression test that actually drives the byte-slice path for a
YEARcolumn throughdata branch diff/ tuple normalization, not just helper-level formatting. - If you want a user-visible proof, a small git4data branch diff case with a
YEARcolumn would lock the full path.
XuPeng-SH
left a comment
There was a problem hiding this comment.
I re-checked the current head from a first-principles / unhappy-path angle. The decimal fixes look useful, but I still see a few substantive type-handling holes in the broader path this PR is touching.
-
CompareValueis still not a valid comparator for several numeric types- The current implementation uses subtraction +
int(...)foruint8/16/32andfloat32/64. - That is not comparator-safe in Go: unsigned subtraction can wrap (
uint8(1)-uint8(2) -> 255), and float deltas smaller than 1 can collapse to0afterint(...). - This matters here because the new data-branch logic relies on
CompareValuefor row comparison and PK sorting. - Suggestion: switch those branches to explicit
< / > / ==comparisons that return-1/0/1, and add tests forfloatdeltas< 1plus ascending/descending unsigned cases.
- The current implementation uses subtraction +
-
Tuple.SQLStrings()no longer returns SQL literals, butfuzzyCheckstill concatenates its output directly into SQLTuple.SQLStrings()now returns raw values for text/date/time/uuid-ish types without quoting/escaping.pkg/sql/compile/fuzzyCheck.gostill injects those strings directly intocol = %spredicates.- So composite keys containing plain strings, dates, timestamps, UUIDs, or embedded quotes can now generate invalid or semantically wrong SQL.
- Suggestion: either restore SQL-literal quoting/escaping in
Tuple.SQLStrings(), or stop using it for SQL generation and quote/parameterize at thefuzzyCheckcall site.
-
YEARis still incomplete across the end-to-end data-branch path- The PR adds some low-level YEAR handling, but the full data-branch diff/pick path still has gaps: normalization, PK extraction, formatting, and decode paths are not consistently updated together.
- In particular,
normalizeTupleColumnValue()/ PK extraction /DecodeValue()are still the choke points for YEAR values coming back as raw bytes. - Suggestion: add explicit
T_yearhandling consistently across encode/decode/normalize/format/PK extraction, then add at least one focusedDATA BRANCH DIFF/PICKregression using YEAR columns.
Given the comparator correctness bug and the Tuple.SQLStrings() SQL-generation regression, I think this should stay at request changes on the current head.
|
Addressed the latest review in
Verification:
Local |
XuPeng-SH
left a comment
There was a problem hiding this comment.
The new compound-key quoting in pkg/sql/compile/fuzzyCheck.go is still semantically wrong.
formatCompoundCollisionKey now uses strconv.Quote, but that produces Go double-quoted / backslash-escaped string literals, not SQL literals. Those values are then concatenated into f.condition and executed by backgroundSQLCheck() via runSqlWithResultAndOptions(), which propagates the current session's variable resolver (WithResolveVariableFunc(...)). So this sub-SQL still runs under the caller's sql_mode behavior.
That leaves at least two real failure modes:
- Under
ANSI_QUOTES, values like"2025-01-03"/"O'Reilly"are no longer string literals, so the duplicate-check SQL for compound keys can parse or evaluate incorrectly. - Under
NO_BACKSLASH_ESCAPES, the Go-style escaping emitted bystrconv.Quoteis also not the right SQL literal escaping, so strings / binary-ish payloads containing backslashes or escapes can be misparsed.
So the new fuzzy-check path is still not SQL-mode-safe for the exact string/date/year/blob/uuid-style cases this patch is trying to fix, and TestFillCompoundConditionQuotesSQLLiterals is currently locking in the wrong representation. Please switch this to repo-consistent single-quoted SQL literal generation (for example the existing tree.WithSingleQuoteString() / SQL-string escaping style used elsewhere) and add a regression that exercises at least ANSI_QUOTES.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Re-reviewed latest head cb18ec8 from the data-flow and unhappy-path angles.
The previously requested blockers look closed now:
- decimal metadata inference no longer hard-codes
length - 2; it accounts for scale/sign and has boundary/error coverage, including signedDECIMAL(19,0)and decimal256. CompareValueno longer uses subtraction/truncation for unsigned/float comparators, and the regression tests cover unsigned direction plus sub-1 float deltas.YEARis now covered consistently across decode/normalize/format/PK extraction/comparison/output surfaces, with helper and BVT coverage.- decimal256 is covered across tuple encode/decode, SQL string formatting, branch diff/pick conversion, logtail replay appendFromEntry, readutil PK filters, lock fetch, and merge sort.
- compound fuzzy-check SQL generation no longer uses Go
strconv.Quote; it uses single-quoted SQL literals throughsqlquote.String, with coverage for embedded quote/backslash and ANSI_QUOTES-sensitive no-double-quote output.
I also checked the latest CI rollup: Summary is green. Local targeted tests passed for the touched hot paths:
./pkg/common/sqlquote./pkg/container/types./pkg/frontend./pkg/sql/compile./pkg/sql/colexec/lockop./pkg/vm/engine/readutil./pkg/objectio/mergeutil./pkg/vm/engine/disttae/logtailreplay./pkg/frontend/databranchutils
Non-blocking: the PR is still marked BEHIND, so it should be updated with latest main before merge if the queue requires it.
Merge Queue Status
This pull request spent 16 minutes 4 seconds in the queue, with no time running CI. ReasonPull request #24894 has been dequeued Queue conditions are not satisfied:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Requeued — the merge queue status continues in this comment ↓. |
Merge Queue Status
This pull request spent 2 hours 46 minutes 44 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull request #24894 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
Failing checks:
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #24847
What this PR does / why we need it:
Port the data branch decimal/year result conversion and tuple handling fixes to latest
main.tree.WithSingleQuoteString().diff_15.sqlfor decimal64/decimal128/decimal256data branch diff,diff_16.sqlfor yeardata branch diff, andpick_12.sql/pick_13.sqlfor pick paths.Notes:
mainat890a3800c44932b4dd190ba59277aa73c502bd05; conflict with upstreamdiff_14.sqlwas resolved by keeping upstreamdiff_14and moving this PR's decimal/year cases todiff_15/diff_16.Checks:
git diff --check upstream/main...HEADpassed.make -C thirdpartiespassed locally.source $HOME/.zshrc && moenv && go test ./pkg/container/types ./pkg/frontend ./pkg/vm/engine/disttae/logtailreplay:pkg/container/typespassed;pkg/frontendandpkg/vm/engine/disttae/logtailreplayare locally blocked by the currentupstream/mainthirdparty mismatch wheregithub.com/unum-cloud/usearch/[email protected]expects symbols such asusearch_scalar_u8_kandusearch_hardware_acceleration_*, butthirdparties/install/include/usearch.hbuilt fromusearch-2.25.3.tar.gzdoes not provide them.