You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "mbaurin (via GitHub)" <gi...@apache.org> on 2025/08/21 13:50:42 UTC
[PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
mbaurin opened a new pull request, #8240:
URL: https://github.com/apache/gravitino/pull/8240
<!--
1. Title: [#<issue>] <type>(<scope>): <subject>
Examples:
- "[#123] feat(operator): support xxx"
- "[#233] fix: check null before access result in xxx"
- "[MINOR] refactor: fix typo in variable name"
- "[MINOR] docs: fix typo in README"
- "[#255] test: fix flaky test NameOfTheTest"
Reference: https://www.conventionalcommits.org/en/v1.0.0/
2. If the PR is unfinished, please mark this PR as draft.
-->
### What changes were proposed in this pull request?
Fixed the `DorisUtils.extractBucketNum()` method to properly handle `BUCKETS AUTO` parsing for `DISTRIBUTED BY RANDOM` statements. The method was incorrectly calling `matcher.find(5)` which advances the matcher position, causing the bucket value extraction to fail and resulting in a `NumberFormatException` when parsing null values.
**Changes:**
- Changed `if (matcher.find(5))` to `if (matcher.group(5) != null)` in `DorisUtils.extractBucketNum()`
- Added test case for `DISTRIBUTED BY RANDOM BUCKETS AUTO` in `TestDorisUtils.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 that `matcher.find(5)` advances the matcher position after the initial match, and since there are no subsequent matches, it returns `false` and never reaches the bucket value extraction logic. This leaves `bucketValue` as null, causing `Integer.valueOf(bucketValue)` to throw `NumberFormatException: 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?
1. **Existing tests**: Verified all existing Doris utility tests continue to pass, ensuring no regression
2. **New test case**: Added `TestDorisUtils.testDistributedInfoPattern()` test case specifically for `DISTRIBUTED BY RANDOM BUCKETS AUTO` to prevent future regressions
3. **Manual verification**: Created and ran a standalone test to reproduce the original bug and verify the fix resolves the `NumberFormatException`
4. **Code formatting**: Applied Spotless formatting to ensure code style compliance
**Test command:**
```
./gradlew :catalogs:catalog-jdbc-doris:test --tests="*TestDorisUtils*"
```
All tests pass successfully with the fix applied.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3243640164
@mbaurin
Please resolve the code format issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3214114203
@mbaurin
Thank you for your help. I have a question? In which version does Doris support the keyword `AUTO`? Currently, Doris catalog is based on version `1.2.x`, I remembered that there is no `AUTO` there, please correct me if I'm wrong.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3214357274
Accordingly to [docs](https://gravitino.apache.org/docs/0.9.1/jdbc-doris-catalog), the version is `1.2.x`, it hard to tell whether it is `1.2.0/1.2.1` or a higher version(1.2.2+)? So, is there any way to support both?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3220116892
> > Accordingly to [docs](https://gravitino.apache.org/docs/0.9.1/jdbc-doris-catalog), the version is `1.2.x`, it hard to tell whether it is `1.2.0/1.2.1` or a higher version(1.2.2+)? So, is there any way to support both?
>
> Good point, here are some approaches to support both:
>
> Option 1: Graceful degradation
>
> * Keep the parsing logic to handle BUCKETS AUTO
> * When actually executing against Doris, if it fails due to unsupported syntax, we could catch the error and provide a
> helpful message
> * This way newer Doris versions work seamlessly, older versions get clear feedback
>
> Option 2: Runtime version detection
>
> * Add a version check against the Doris instance
> * Parse BUCKETS AUTO only if version >= 1.2.2
> * Requires adding version detection logic to the catalog
>
> Option 3: Configuration-based
>
> * Add a catalog property like doris.support.auto.buckets=true/false
> * Let users configure based on their Doris version
> * Default to false for backward compatibility
>
> Option 4: Keep current approach
>
> * The existing codebase already had partial AUTO support (HASH variant worked)
> * This suggests the maintainers expected AUTO support
> * We're just fixing the RANDOM variant bug
>
> I'd lean toward Option 1, it's the least disruptive and provides the best user experience. What do you think?
Yeah, solution one is more graceful, and the change is less intrusive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "mbaurin (via GitHub)" <gi...@apache.org>.
mbaurin commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3242010671
@yuqi1129 Option 1 implemented 👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "mbaurin (via GitHub)" <gi...@apache.org>.
mbaurin commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3244599806
> @mbaurin
>
> Please resolve the code format issue.
done @yuqi1129
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "mbaurin (via GitHub)" <gi...@apache.org>.
mbaurin commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3214268777
> @mbaurin Thank you for your help. I have a question? In which version does Doris support the keyword `AUTO`? Currently, Doris catalog is based on version `1.2.x`, I remembered that there is no `AUTO` there, please correct me if I'm wrong.
Thanks for raising this! I did some research and found that BUCKETS AUTO was actually introduced in Apache Doris 1.2.2, not earlier 1.2.x versions.
From the Doris 1.2.2 release notes and documentation:
- Feature was added as "Auto Bucket" in 1.2.2
- The 1.2-lts branch has regression tests for BUCKETS AUTO dating from April 2023
- It's not available in 1.2.0/1.2.1
What specific Doris version is Gravitino's catalog currently targeting? If we're supporting 1.2.2+, then this fix is valid. If we're still on 1.2.0/1.2.1, we might need to either:
1. Keep the fix - if we want forward compatibility with 1.2.2+
2. Add version validation - reject BUCKETS AUTO syntax for older versions
3. Update our target Doris version - if it's time to move to 1.2.2+
The existing codebase already had partial support for this (the HASH variant was working), so it seems like there was already some expectation of BUCKETS AUTO support.
What's your preference on how to handle this version compatibility ? Happy to adjust the approach accordingly !
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "yuqi1129 (via GitHub)" <gi...@apache.org>.
yuqi1129 merged PR #8240:
URL: https://github.com/apache/gravitino/pull/8240
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#8218] fix(doris): Fix BUCKETS AUTO parsing for RANDOM distribution [gravitino]
Posted by "mbaurin (via GitHub)" <gi...@apache.org>.
mbaurin commented on PR #8240:
URL: https://github.com/apache/gravitino/pull/8240#issuecomment-3214373751
> Accordingly to [docs](https://gravitino.apache.org/docs/0.9.1/jdbc-doris-catalog), the version is `1.2.x`, it hard to tell whether it is `1.2.0/1.2.1` or a higher version(1.2.2+)? So, is there any way to support both?
Good point, here are some approaches to support both:
Option 1: Graceful degradation (Recommended)
- Keep the parsing logic to handle BUCKETS AUTO
- When actually executing against Doris, if it fails due to unsupported syntax, we could catch the error and provide a
helpful message
- This way newer Doris versions work seamlessly, older versions get clear feedback
Option 2: Runtime version detection
- Add a version check against the Doris instance
- Parse BUCKETS AUTO only if version >= 1.2.2
- Requires adding version detection logic to the catalog
Option 3: Configuration-based
- Add a catalog property like doris.support.auto.buckets=true/false
- Let users configure based on their Doris version
- Default to false for backward compatibility
Option 4: Keep current approach
- The existing codebase already had partial AUTO support (HASH variant worked)
- This suggests the maintainers expected AUTO support
- We're just fixing the RANDOM variant bug
I'd lean toward Option 1 - it's the least disruptive and provides the best user experience. What do you think?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org