morrySnow opened a new pull request, #62166:
URL: https://github.com/apache/doris/pull/62166
### What problem does this PR solve?
Problem Summary:
`DecimalLiteral.init()` directly calls
`SessionVariable.getEnableDecimal256()` to determine the maximum decimal
precision, coupling `analysis.DecimalLiteral` with `qe.SessionVariable`. This
makes it difficult to construct `DecimalLiteral` in contexts where no session
exists and violates separation of concerns.
### Changes
1. **Created `DecimalLiteralUtils`** — a new helper class with static
factory methods:
- `create(String)` — convenience wrapper that reads `enableDecimal256`
from session
- `create(String, boolean enableDecimal256)` — session-free core logic
- `create(BigDecimal, boolean enableDecimal256)` — BigDecimal variant
2. **Removed from `DecimalLiteral`**:
- `DecimalLiteral(String)` constructor
- `DecimalLiteral(BigDecimal)` constructor
- `init(BigDecimal)` and `init(BigDecimal, boolean)` methods
- Imports of `SessionVariable`, `ScalarType`, `Config`
3. **Fixed `compareLiteral()`** — now uses direct `BigDecimal.compareTo()`
instead of constructing a temporary `DecimalLiteral`
4. **Removed `VariableExpr.setDecimalValue()`** and
**`ConnectContext.fillValueForUserDefinedVar()`** — dead code that used the
removed constructor
5. **Updated all callers** in `LiteralExpr`, `ColumnDef`, `StatisticsUtil`,
`ConnectProcessor`
6. **Added 22 unit tests** in `DecimalLiteralUtilsTest` covering normal
values, edge cases, boundary precision, decimal256, trailing zeros, invalid
input, etc.
### Release note
None
### Check List (For Author)
- Test: Unit Test (22 test cases in DecimalLiteralUtilsTest)
- Behavior changed: No
- Does this need documentation: No
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]