[#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution #8447
+39
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Fixed the
DorisUtils.extractBucketNum()
method to properly handleBUCKETS AUTO
parsing forDISTRIBUTED BY RANDOM
statements. The method was incorrectly callingmatcher.find(5)
which advances the matcher position, causing the bucket value extraction to fail and resulting in aNumberFormatException
when parsing null values.Changes:
if (matcher.find(5))
toif (matcher.group(5) != null)
inDorisUtils.extractBucketNum()
DISTRIBUTED BY RANDOM BUCKETS AUTO
inTestDorisUtils.testDistributedInfoPattern()
Why are the changes needed?
This fixes a critical bug where Doris table operations fail when encountering
DISTRIBUTED BY RANDOM BUCKETS AUTO
syntax. The root cause was thatmatcher.find(5)
advances the matcher position after the initial match, and since there are no subsequent matches, it returnsfalse
and never reaches the bucket value extraction logic. This leavesbucketValue
as null, causingInteger.valueOf(bucketValue)
to throwNumberFormatException: Cannot parse null string
.The bug affects users trying to load tables with auto bucket distribution using random strategy, which is a valid Doris SQL syntax.
Fix: #8218
Does this PR introduce any user-facing change?
No user-facing API changes. This is a bug fix that enables proper parsing of existing Doris SQL syntax that was previously failing. Users can now successfully work with tables using
DISTRIBUTED BY RANDOM BUCKETS AUTO
without encountering parsing errors.How was this patch tested?
TestDorisUtils.testDistributedInfoPattern()
test case specifically forDISTRIBUTED BY RANDOM BUCKETS AUTO
to prevent future regressionsNumberFormatException
Test command:
All tests pass successfully with the fix applied.