jacktengg opened a new pull request, #71040:
URL: https://github.com/apache/doris/pull/71040

   ### Background
   
   WIDTH_BUCKET assigns numeric values to equal-width buckets and returns a 
BIGINT bucket number. The bucket count must be constant, and nullable arguments 
propagate NULL.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #14396 (introduced the integer bucket-width guard)
   PR Type: Bugfix
   
   Problem Summary:
   
   Integer bucket widths below one return bucket 0, and signed bounds can 
overflow during subtraction. Invalid counts can overflow the upper outside 
bucket or become valid after LARGEINT narrowing. Preserve full-width arithmetic 
and validate counts, equal bounds, and nonfinite inputs while keeping NULL 
propagation.
   
   ### Details
   
   - **Change map:** 131 changed production lines and 184 changed test/result 
lines. BE handles arithmetic and NULL boundaries; FE validates the original 
count; tests cover these paths.
   - **Frequency:** Not observed in a new runtime execution; confirmed by 
source inspection. The baseline returns 0 for width_bucket(-1, -1, 0, 2) 
because integer division truncates the bucket width to zero; the transplanted 
logic computes 1.
   - **Root cause:** Bucket widths and distances are calculated in the input 
integer type, and counts are not checked against the BIGINT result range before 
narrowing.
   - **Why existing tests missed it:** The FE constant-argument tests cover 
folding and constness, and the regression suite covers ordinary positive inputs 
and zero counts. Neither covers unit-width negative intervals, full-width 
counts, independent NULL arguments, or nonfinite bounds. No dedicated BE 
WIDTH_BUCKET test existed on the base.
   - **Fix:** Selectively transplant the WIDTH_BUCKET changes and required 
IntegerLikeLiteral helper from d73c2e12a5d74a89e7a58cb6ef666ae16a3f6a0d. 
Extract only related BE, FE, and regression cases from mixed test files. 
Production changes originated in 9d5800474da; the source tip also contains 
later test coverage.
   - **Other paths and branches:** All six supported BE physical numeric types 
share the fix. FE validates before coercion and after rewrite. Local 
origin/branch-3.1, branch-4.0, branch-4.1, and branch-4.2 snapshots retain the 
zero-width guard; no backports are included.
   - **Behavior change:** Narrow integer intervals and signed boundaries 
produce valid bucket numbers. Invalid counts, equal bounds, and nonfinite 
inputs report errors. Negative values and NULL arguments remain supported.
   
   ### Testing
   
   Passed local checks: production source equality, extraction checks for five 
BE tests and two FE assertions, clang-format 16 via repository scripts on the 
changed C++ files, Checkstyle on the three changed Java files across two runs, 
and build-support/check-build-hygiene.sh. Whitespace checks pass with the 
existing generated .out block's trailing separator retained.
   
   Full compilation, runtime unit/regression tests, and clang-tidy were not run 
for this selective transplant. The regression result block was copied verbatim 
from the source branch's existing generated output, not handwritten or 
regenerated in this task.
   
   ### Release note
   
   Fix WIDTH_BUCKET results for narrow integer intervals and full-width signed 
bounds, preserve NULL results, and reject invalid bucket counts, equal bounds, 
and nonfinite inputs.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: Yes; document the count upper bound and 
invalid-bound/nonfinite errors in the WIDTH_BUCKET reference before publication.
   - Pre-submission status: Partially verified: full build, runtime 
unit/regression tests, and clang-tidy not run.
   
   ### AI Disclosure
   
   - Tool: OpenAI Codex
   - Generated: Selective patch extraction, test separation and fixture 
reduction, commit description, and verification notes.
   - Human review: Not recorded.
   
   <!-- Recommended: develop the change with the develop-with-evidence skill 
and write this description with the doris-pr-description skill, both from 
https://github.com/apache/doris-skills (the doris-skills submodule of this 
repository). -->
   
   ### Background
   
   <!-- How the feature or module this PR touches works today, in two to four 
plain sentences, for a reviewer who doesn't know it. Link the user doc if there 
is one. Leave the problem and the fix to Problem Summary. -->
   
   ### What problem does this PR solve?
   
   <!-- Issue Number: "close #N" if this PR resolves the issue, "#N" if it only 
relates to it, "None" if there is none. A Feature needs an issue. -->
   <!-- Related PR: "#N (relation)" for each PR a reviewer should know about, 
such as "#123 (introduced the bug)", separated by commas. Write "None" if no 
related PR is known. -->
   <!-- PR Type: Bugfix, Performance, Feature, Enhancement, Refactor, Test, 
Build/CI/Chore, Revert, Release/Dependency, or Other. -->
   
   Issue Number:
   Related PR:
   PR Type:
   
   Problem Summary:
   
   <!-- Two to five sentences: the problem or need and who is affected; the 
approach in one sentence; when the diff is larger than that suggests, what else 
it had to handle, or that most of it is tests; and what existing users see 
after an upgrade. -->
   
   ### Details
   
   <!--
   For a diff of more than about 300 changed lines, start with "- **Change 
map:**": how many lines are production code, tests, generated files, and docs, 
then the code in parts, each with the problem it handles and its size.
   Then answer each field of your PR type on its own line, as "- **Field:** 
answer", in this order:
     Bugfix: Frequency, Root cause, Why existing tests missed it, Fix, Other 
paths and branches
     Performance: Why it was slow, Optimization, Results, Applicability and cost
     Feature: Scope, Design, Usage, Default behavior, Compatibility
     Enhancement: Before and after, Configs and defaults, Impact on existing 
users
     Refactor: Moves vs. logic changes, Behavior change, Compatibility, 
Performance impact, Rollback
     Test, adding tests: Scenarios, What existing tests miss, Fails when broken
     Test, fixing a test: Failure, Cause, Stability evidence
     Build/CI/Chore: Affected, Developer and release impact, License and 
third-party, Rollback
     Revert: Why not fix forward, Original author notified, Follow-up
     Release/Dependency: Versions, Upstream changes, Compatibility, Rollback
     Other: Why Other
   "None" is a valid answer when it is true. Don't restate the diff.
   -->
   
   ### Testing
   
   <!-- The tests, suites, or commands that ran, what each shows, and where it 
ran (locally or in CI). For a fix, the test that fails before it and passes 
after. -->
   
   ### Notes for Reviewers
   
   <!-- Optional; delete this section if there is nothing to say. Why each 
non-obvious edit was made, what you are unsure about, and where to start 
reading if Details has no Change map. -->
   
   ### Release note
   
   <!-- One paragraph on what users will notice, or None. -->
   
   ### Check List (For Author)
   
   <!-- Behavior changed: "No", or "Yes (see Details)" with a Behavior change 
field in Details. -->
   <!-- Does this need documentation: "No", or "Yes" with the 
apache/doris-website PR or the plan. -->
   <!-- Pre-submission status: "Ready"; "Partially verified: " and what is not 
verified; or "Not ready: " and why, for a Draft PR. -->
   
   - Behavior changed:
   - Does this need documentation:
   - Pre-submission status:
   
   ### AI Disclosure
   
   <!-- Tool: the agent and model, or None. Generated: the parts it wrote 
(code, tests, this description), or None. Human review: what you reviewed of 
the generated parts, or "Not applicable" without AI tools. You may add "- 
Prompts:" to summarize how you directed the agent. -->
   
   - Tool:
   - Generated:
   - Human review:
   


-- 
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]

Reply via email to