Skip to content

Support trim_array function - #67397

Open
vajaw wants to merge 1 commit into
apache:masterfrom
vajaw:feature/trim-array
Open

Support trim_array function#67397
vajaw wants to merge 1 commit into
apache:masterfrom
vajaw:feature/trim-array

Conversation

@vajaw

@vajaw vajaw commented Sep 1, 2026

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: Related to #48203

Related PR:
apache/doris-website#4106

Problem Summary:

Add the trim_array(array, n) scalar function. The BE implementation
trims trailing elements directly from array storage and avoids virtual
function calls in the hot loop.

Register the function and its signature in the Nereids planner. Add FE
constant folding so constant invocations can be evaluated during
planning.

Cover normal and constant columns, NULL values, nullable elements,
nested arrays, multiple element types, zero, negative and out-of-range
sizes, and the maximum BIGINT value.

Release note

Add the TRIM_ARRAY scalar function.

Check List (For Author)

  • Test
    • 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

Test results:

  • BE ASAN build passed.

  • FunctionArrayTrimTest.all_argument_combinations passed.

  • FE unit tests passed: 2 tests, 0 failures and 0 errors.

  • The trim_array regression suite passed with no mismatches.

  • run-be-ut.sh and run-regression-test.sh completed
    successfully for the relevant tests.

  • Behavior changed:

    • No.
    • Yes. Adds the new trim_array scalar function.
  • Does this need documentation?

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

Implement trim_array in BE and register its Nereids signature.

Add constant folding, BE tests for const-column combinations, and
regression coverage for nulls, nested arrays, boundary sizes, and types.

Related to apache#48203
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@vajaw

vajaw commented Sep 2, 2026

Copy link
Copy Markdown
Author

/review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants