Uh oh!
There was an error while loading. Please reload this page.
[refine](core) add compile-time safety checks to assert_cast - #63133
Conversation
Mryange
commented
May 11, 2026
/review |
hello-stephen
commented
May 11, 2026
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
There was a problem hiding this comment.
Review result: no blocking issues found in the actual PR diff. The change adds compile-time constraints to assert_cast and is consistent with the helper's existing downcast-only runtime contract; representative usages are class pointer/reference downcasts from common base types.
Critical checkpoints:
- Goal/test: The PR aims to reject unrelated/upcast assert_cast misuse at compile time. The code implements that for class pointer/reference downcasts. No dedicated test was added; given this is a compile-time constraint in a heavily used template, existing BE compilation should cover compatibility.
- Scope/focus: The change is small and focused in be/src/core/assert_cast.h.
- Concurrency/lifecycle/config/compatibility: Not applicable; no runtime state, persistence, protocol, or config changes.
- Parallel code paths: Not applicable; this is the single assert_cast implementation.
- Error handling: Runtime error behavior is unchanged for valid template instantiations that keep checks enabled.
- Memory/data correctness: Not applicable; no allocation, storage, or data visibility changes.
- Performance: No runtime overhead added beyond compile-time static_asserts.
- Observability: Not applicable.
User focus: No additional user-provided review focus was present.
Mryange
commented
May 11, 2026
run buildall |
hello-stephen
commented
May 11, 2026
TPC-H: Total hot run time: 29688 ms |
hello-stephen
commented
May 11, 2026
TPC-DS: Total hot run time: 170749 ms |
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
hello-stephen
commented
May 12, 2026
skip check_coverage |
Uh oh!
There was an error while loading. Please reload this page.
…63133) ### What problem does this PR solve? Issue Number: N/A Problem Summary: `assert_cast` previously only performed runtime type checks (via `typeid` comparison). Misuse — such as casting between unrelated types or upcasting — would only be caught at runtime, making it easy for incorrect usage to slip into release builds where `TypeCheckOnRelease::DISABLE` turns checks into `static_cast` without any verification. This catches invalid casts at build time instead of producing undefined behavior or hard-to-diagnose runtime errors. (cherry picked from commit df8bf16)
### What problem does this PR solve? #63059#63133#63093 ### 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: apache/doris-website#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 -->
### What problem does this PR solve? Issue Number: close #N/A Problem Summary: BE-UT has been failing master-wide since both PR apache#63491 (which strongly typed `ColumnNullable::get_null_map_column[_ptr]()` to `ColumnUInt8`) and PR apache#63049 (which added `functions_geo_test.cpp`) landed today. The new test calls ```cpp assert_cast<ColumnUInt8*>(nullable_input->get_null_map_column_ptr().get()) ->insert_value(0); ``` but the inner expression is already `ColumnUInt8*`, so the cast triggers the same-type static_assert added by PR apache#63133 to `src/core/assert_cast.h`: ``` static assertion failed due to requirement '!std::is_same_v<doris::ColumnVector<doris::TYPE_BOOLEAN> *, doris::ColumnVector<doris::TYPE_BOOLEAN> *>': assert_cast is redundant for the same type after removing cv/ref qualifiers ``` That kills `doris_be_test` compilation on every PR that runs BE-UT. Use the strongly typed `get_null_map_column()` (which returns `ColumnUInt8&`) directly so the cast is no longer needed. ### Release note None (test-only change, restores BE-UT compilation on master). ### Check List (For Author) - Test: - Compile-check on local ASAN tree: the affected translation unit now builds clean (`ninja test/CMakeFiles/doris_be_test.dir/exprs/function/geo/functions_geo_test.cpp.o`). - Behavior changed: No - Does this need documentation: No
…63133) ### What problem does this PR solve? Issue Number: N/A Problem Summary: `assert_cast` previously only performed runtime type checks (via `typeid` comparison). Misuse — such as casting between unrelated types or upcasting — would only be caught at runtime, making it easy for incorrect usage to slip into release builds where `TypeCheckOnRelease::DISABLE` turns checks into `static_cast` without any verification. This catches invalid casts at build time instead of producing undefined behavior or hard-to-diagnose runtime errors.
What problem does this PR solve?
Issue Number: N/A
Problem Summary:
assert_castpreviously only performed runtime type checks (viatypeidcomparison). Misuse — such as casting between unrelated types or upcasting — would only be caught at runtime, making it easy for incorrect usage to slip into release builds whereTypeCheckOnRelease::DISABLEturns checks intostatic_castwithout any verification.This catches invalid casts at build time instead of producing undefined behavior or hard-to-diagnose runtime errors.
Release note
None
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)