Mryange opened a new pull request, #61996:
URL: https://github.com/apache/doris/pull/61996
### What problem does this PR solve?
Problem Summary:
`DataTypeNumberSerDe<T>` was a monolithic template class serving as both the
base class for all number-like SerDe types and the concrete implementation for
pure numeric types. It handled 17+ types via extensive `if constexpr` branches,
making the code hard to read and maintain. The inheritance structure was also
asymmetric with the DataType side.
This PR performs a multi-phase refactoring:
**Phase 1 — Split base class and add thin final wrapper**
- Rename `DataTypeNumberSerDe<T>` → `DataTypeNumberSerDeBase<T>` (base class)
- Add `DataTypeNumberSerDe<T> final` for pure numeric types
(Bool/Int/Float/Double/Time), mirroring `DataTypeNumber<T>` on the DataType side
**Phase 3 — Lift `get_scale()` to `DataTypeSerDe` base**
- Move `get_scale()` from `DataTypeNumberSerDeBase<T>` to `DataTypeSerDe`,
making it available to all SerDe types (e.g. Decimal)
**Phase 4 — Split Date/DateTime v1 SerDe into separate files**
- Create `DataTypeDateLikeV1SerDe<T>` shared template for Date/DateTime v1
common logic
- Split into `data_type_date_serde.h/.cpp` and
`data_type_datetime_serde.h/.cpp`
- `DataTypeDateSerDe` and `DataTypeDateTimeSerDe` are now siblings (not
parent-child)
**Phase 2 — Sink `if constexpr` branches to subclasses**
- Move type-specific PB/Jsonb serialization logic from
`DataTypeNumberSerDeBase<T>` into subclass overrides:
- `DataTypeDateLikeV1SerDe<T>`: write/read PB (INT64), write/read Jsonb
- `DataTypeDateV2SerDe`: write/read PB (UINT32), write/read Jsonb
- `DataTypeDateTimeV2SerDe`: write/read PB (UINT64), write/read Jsonb
- `DataTypeTimeStampTzSerDe`: write/read PB (UINT64), write/read Jsonb,
read_column_from_arrow
- `DataTypeIPv4SerDe`: write/read Jsonb
- Remove corresponding dead branches from the base class
After refactoring, the base class `DataTypeNumberSerDeBase<T>` PB methods
only handle pure numeric types (Bool, TinyInt–BigInt, LargeInt, Float, Double,
Time/TimeV2).
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
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]