Repository navigation
fix: align SOUNDEX with MySQL semantics - #28760
Conversation
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? |
209e774 to
71b8664
Compare
71b8664 to
795585f
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed head e835bc2ed746dea13bdf1cf7988706e94dfdcbf7 against base/merge-base 2d18131682dba1847696b4a02bd8aa4271904736. No remaining blocking issue found in the full diff. The result-width issue from my previous review is resolved.
All three SOUNDEX overloads now derive a safe result capacity: a four-character minimum, VARCHAR where the bound fits, and wider TEXT for large or unknown bounds. I traced that type into CTAS; the new registry and CTAS-plan tests cover metadata, and BVT now materializes and reads the 65,535/65,536 boundary values. The 65,538-byte helper test retains full byte-for-byte verification.
The ASCII algorithm agrees with MySQL's original Soundex implementation: first-letter suppression, discarded-character handling, empty/no-letter results, padding, and variable-length output. The shared wrapper retains constant/NULL/selection behavior and propagates append failures. Runtime work remains linear in input length; output storage grows with emitted bytes, without a full-input uppercase allocation. The type calculation adds only planning-time work. The documented multibyte limitation remains outside this PR's ASCII contract.
Validation reused: successful SCA, UT, UT Coverage, shared build, both substantive BVT jobs, and CI Required for this head in run 34687134875. No additional broad test run or code change was needed.
Non-blocking: please refresh the PR description's claims that overload metadata is unchanged and CI is pending; both are now outdated. Submitted as COMMENT because this is the account owner's PR.
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes #28781 ## What this PR does / why we need it: - Reduce the functional Arrow record-batch fanout fixture from 100,000 to 25,600 rows while retaining all 100 IPC record batches. A runtime size assertion keeps it above the 1 MiB LOAD threshold, and the full row identity/payload checks remain. The 100,000-row benchmark fixture is unchanged. - Make LocalMinIO bucket setup idempotent only for `BucketAlreadyOwnedByYou`, which can follow a server-side bucket create whose response was lost. Other errors remain failures. - Add a deterministic lost-response test using the MinIO SDK and an in-process HTTP server. - No production SQL behavior changes. ## Test Plan - On the 55 Linux/x86 host: full `TestArrowLoadBVT` (including `DistributedRecordBatchFanout` and `LocalMinIO`) passed; `TestArrowLoadForceMaterializeFallback` passed. - `TestArrowLoadBucketCreateComplete`, `TestArrowLoadBucketRetryAfterLostCreateResponse`, and `TestRetryArrowLoadBucketStopsOnCancellation` passed normally and under `-race`. - `go vet -mod=readonly ./pkg/tests/arrowload`, gofmt, and `git diff --check` passed. - The 55-host test evidence used the unchanged source diff before rebasing; the rebase added only upstream #28751 and #28760, which do not touch the Arrow LOAD test paths. CI on the final head has not been awaited. - Local golangci-lint could not run because the installed binary targets Go 1.24.4 while this repository requires Go 1.26.4; CI static analysis remains the final check. - The fanout case is smaller by row count while preserving its batch count and LOAD path. Timing samples varied, so this PR does not claim a statistically established end-to-end suite speedup.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28212 ## What this PR does / why we need it: `SOUNDEX()` currently truncates the result to four characters, returns `0000` for empty/no-letter input, and does not suppress a consonant code matching the retained first letter. These produce incorrect results for MySQL-compatible inputs such as `Ashcraft` and `Pfister`. This implements MySQL's original Soundex behavior for ASCII input: retain the first letter, seed duplicate suppression from its code, discard code-zero characters before duplicate suppression, preserve codes beyond four characters, and pad only non-empty results shorter than four. The one-pass byte scan also avoids allocating a full uppercase copy. Output memory grows with emitted code bytes; it is not preallocated to the full input length. MySQL calls this the original—not enhanced—Soundex algorithm and documents variable-length results and `Quadratically -> Q36324`: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html. The issue's MySQL 8.3 examples remain the compatibility oracle. Regression coverage adds issue examples, first-letter and discarded-character duplicate cases, empty/no-letter versus NULL, variable-length and capacity-boundary results, mixed-case input, VARCHAR/CHAR columns, prepared execution, and a TEXT result of 65,538 bytes. The function unit test checks every output byte for that long result. ### Validation - Rebased onto `main` at `4f9d170a22deaabc2eee6b239a51a8cb40a39f9f`. - After rebase, `GOMAXPROCS=6 go test -p=1 ./pkg/sql/plan/function -run '^TestSoundex(LongTextOutput)?$' -count=1` passed. - An embedded SQL probe confirmed the 65,538-byte TEXT result, byte-for-byte output, and short prefix/suffix checks. - The previous full BVT run failed only at the whole-string equality assertion for two 65,538-byte strings. The embedded reproduction returned byte-identical strings while SQL `=` returned false; the distributed test now checks the total length and short HEX prefix/suffix. Full output equality remains covered by `TestSoundexLongTextOutput`. - `git diff --check` and GPT-6 medium final review passed on the rebased head. - Before this rebase, incremental `golangci-lint` for `./pkg/sql/plan/function` passed with 0 issues; `go vet -vettool=molint` exited 0 and printed the existing diagnostic in unchanged `byte_like_wildcard_search.go:17`. - Fresh CI for the rebased head is pending. ### Scope and remaining limitation This change targets ASCII Soundex compatibility. It does not add Unicode transliteration or promise consistent results for multibyte input; MySQL documents that multibyte Soundex results are not guaranteed to be consistent. The existing SQL wrapper, NULL/selection handling, and VARCHAR overload metadata remain unchanged.
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28781 ## What this PR does / why we need it: - Reduce the functional Arrow record-batch fanout fixture from 100,000 to 25,600 rows while retaining all 100 IPC record batches. A runtime size assertion keeps it above the 1 MiB LOAD threshold, and the full row identity/payload checks remain. The 100,000-row benchmark fixture is unchanged. - Make LocalMinIO bucket setup idempotent only for `BucketAlreadyOwnedByYou`, which can follow a server-side bucket create whose response was lost. Other errors remain failures. - Add a deterministic lost-response test using the MinIO SDK and an in-process HTTP server. - No production SQL behavior changes. ## Test Plan - On the 55 Linux/x86 host: full `TestArrowLoadBVT` (including `DistributedRecordBatchFanout` and `LocalMinIO`) passed; `TestArrowLoadForceMaterializeFallback` passed. - `TestArrowLoadBucketCreateComplete`, `TestArrowLoadBucketRetryAfterLostCreateResponse`, and `TestRetryArrowLoadBucketStopsOnCancellation` passed normally and under `-race`. - `go vet -mod=readonly ./pkg/tests/arrowload`, gofmt, and `git diff --check` passed. - The 55-host test evidence used the unchanged source diff before rebasing; the rebase added only upstream matrixorigin#28751 and matrixorigin#28760, which do not touch the Arrow LOAD test paths. CI on the final head has not been awaited. - Local golangci-lint could not run because the installed binary targets Go 1.24.4 while this repository requires Go 1.26.4; CI static analysis remains the final check. - The fanout case is smaller by row count while preserving its batch count and LOAD path. Timing samples varied, so this PR does not claim a statistically established end-to-end suite speedup.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28212 ## What this PR does / why we need it: `SOUNDEX()` currently truncates the result to four characters, returns `0000` for empty/no-letter input, and does not suppress a consonant code matching the retained first letter. These produce incorrect results for MySQL-compatible inputs such as `Ashcraft` and `Pfister`. This implements MySQL's original Soundex behavior for ASCII input: retain the first letter, seed duplicate suppression from its code, discard code-zero characters before duplicate suppression, preserve codes beyond four characters, and pad only non-empty results shorter than four. The one-pass byte scan also avoids allocating a full uppercase copy. Output memory grows with emitted code bytes; it is not preallocated to the full input length. MySQL calls this the original—not enhanced—Soundex algorithm and documents variable-length results and `Quadratically -> Q36324`: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html. The issue's MySQL 8.3 examples remain the compatibility oracle. Regression coverage adds issue examples, first-letter and discarded-character duplicate cases, empty/no-letter versus NULL, variable-length and capacity-boundary results, mixed-case input, VARCHAR/CHAR columns, prepared execution, and a TEXT result of 65,538 bytes. The function unit test checks every output byte for that long result. ### Validation - Rebased onto `main` at `4f9d170a22deaabc2eee6b239a51a8cb40a39f9f`. - After rebase, `GOMAXPROCS=6 go test -p=1 ./pkg/sql/plan/function -run '^TestSoundex(LongTextOutput)?$' -count=1` passed. - An embedded SQL probe confirmed the 65,538-byte TEXT result, byte-for-byte output, and short prefix/suffix checks. - The previous full BVT run failed only at the whole-string equality assertion for two 65,538-byte strings. The embedded reproduction returned byte-identical strings while SQL `=` returned false; the distributed test now checks the total length and short HEX prefix/suffix. Full output equality remains covered by `TestSoundexLongTextOutput`. - `git diff --check` and GPT-6 medium final review passed on the rebased head. - Before this rebase, incremental `golangci-lint` for `./pkg/sql/plan/function` passed with 0 issues; `go vet -vettool=molint` exited 0 and printed the existing diagnostic in unchanged `byte_like_wildcard_search.go:17`. - Fresh CI for the rebased head is pending. ### Scope and remaining limitation This change targets ASCII Soundex compatibility. It does not add Unicode transliteration or promise consistent results for multibyte input; MySQL documents that multibyte Soundex results are not guaranteed to be consistent. The existing SQL wrapper, NULL/selection handling, and VARCHAR overload metadata remain unchanged.
## What type of PR is this? - [ ] API-change - [ ] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Fixes matrixorigin#28781 ## What this PR does / why we need it: - Reduce the functional Arrow record-batch fanout fixture from 100,000 to 25,600 rows while retaining all 100 IPC record batches. A runtime size assertion keeps it above the 1 MiB LOAD threshold, and the full row identity/payload checks remain. The 100,000-row benchmark fixture is unchanged. - Make LocalMinIO bucket setup idempotent only for `BucketAlreadyOwnedByYou`, which can follow a server-side bucket create whose response was lost. Other errors remain failures. - Add a deterministic lost-response test using the MinIO SDK and an in-process HTTP server. - No production SQL behavior changes. ## Test Plan - On the 55 Linux/x86 host: full `TestArrowLoadBVT` (including `DistributedRecordBatchFanout` and `LocalMinIO`) passed; `TestArrowLoadForceMaterializeFallback` passed. - `TestArrowLoadBucketCreateComplete`, `TestArrowLoadBucketRetryAfterLostCreateResponse`, and `TestRetryArrowLoadBucketStopsOnCancellation` passed normally and under `-race`. - `go vet -mod=readonly ./pkg/tests/arrowload`, gofmt, and `git diff --check` passed. - The 55-host test evidence used the unchanged source diff before rebasing; the rebase added only upstream matrixorigin#28751 and matrixorigin#28760, which do not touch the Arrow LOAD test paths. CI on the final head has not been awaited. - Local golangci-lint could not run because the installed binary targets Go 1.24.4 while this repository requires Go 1.26.4; CI static analysis remains the final check. - The fanout case is smaller by row count while preserving its batch count and LOAD path. Timing samples varied, so this PR does not claim a statistically established end-to-end suite speedup.
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #28212
What this PR does / why we need it:
SOUNDEX()currently truncates the result to four characters, returns0000for empty/no-letter input, and does not suppress a consonant code matching the retained first letter. These produce incorrect results for MySQL-compatible inputs such asAshcraftandPfister.This implements MySQL's original Soundex behavior for ASCII input: retain the first letter, seed duplicate suppression from its code, discard code-zero characters before duplicate suppression, preserve codes beyond four characters, and pad only non-empty results shorter than four. The one-pass byte scan also avoids allocating a full uppercase copy. Output memory grows with emitted code bytes; it is not preallocated to the full input length.
MySQL calls this the original—not enhanced—Soundex algorithm and documents variable-length results and
Quadratically -> Q36324: https://dev.mysql.com/doc/refman/8.4/en/string-functions.html. The issue's MySQL 8.3 examples remain the compatibility oracle.Regression coverage adds issue examples, first-letter and discarded-character duplicate cases, empty/no-letter versus NULL, variable-length and capacity-boundary results, mixed-case input, VARCHAR/CHAR columns, prepared execution, and a TEXT result of 65,538 bytes. The function unit test checks every output byte for that long result.
Validation
mainat4f9d170a22deaabc2eee6b239a51a8cb40a39f9f.GOMAXPROCS=6 go test -p=1 ./pkg/sql/plan/function -run '^TestSoundex(LongTextOutput)?$' -count=1passed.=returned false; the distributed test now checks the total length and short HEX prefix/suffix. Full output equality remains covered byTestSoundexLongTextOutput.git diff --checkand GPT-6 medium final review passed on the rebased head.golangci-lintfor./pkg/sql/plan/functionpassed with 0 issues;go vet -vettool=molintexited 0 and printed the existing diagnostic in unchangedbyte_like_wildcard_search.go:17.Scope and remaining limitation
This change targets ASCII Soundex compatibility. It does not add Unicode transliteration or promise consistent results for multibyte input; MySQL documents that multibyte Soundex results are not guaranteed to be consistent. The existing SQL wrapper, NULL/selection handling, and VARCHAR overload metadata remain unchanged.