floation-cutie opened a new pull request, #60892:
URL: https://github.com/apache/doris/pull/60892

   ### What problem does this PR solve?
   
   Issue Number: close #55788
   
   Related PR: #55788
   
   Problem Summary:
     This PR implements the enhancement requested in issue #55788, adding an 
optional third parameter `limit` to the `SPLIT_BY_STRING` function. The `limit` 
parameter controls the maximum number of splits to perform, limiting the size 
of the returned array.
   
     ## Solution
   
     - Add optional third parameter `limit` to `SPLIT_BY_STRING(<str>, 
<separator>[, <limit>])`
     - When `limit` is positive: split from left, at most `limit` splits, 
returning at most `limit + 1` elements
     - When `limit` is negative: split from right, at most `|limit|` splits 
from the end
     - When `limit` is not specified or -1: split all occurrences (backward 
compatible)
     - Update BE function implementation in `function_string.cpp` and 
`function_string.h`
     - Update FE function definition in `SplitByString.java` and 
`StringArithmetic.java`
     - Add constant folding support for the new parameter
   
     Examples:
     ```sql
     SELECT SPLIT_BY_STRING('one,two,three,', ',');       -- ["one", "two", 
"three", ""]
     SELECT SPLIT_BY_STRING('one,two,three,', ',', -1);   -- ["one", "two", 
"three", ""]
     SELECT SPLIT_BY_STRING('one,two,three,', ',', 2);    -- ["one", 
"two,three,"]
     SELECT SPLIT_BY_STRING('one,two,three,', ',', 3);    -- ["one", "two", 
"three,"]
     SELECT SPLIT_BY_STRING('one,two,three,', ',', 4);    -- ["one", "two", 
"three", ""]
     SELECT SPLIT_BY_STRING('one,two,three,', ',', 5);    -- ["one", "two", 
"three", ""]
   ```
   
   ### Release note
   
   [Enhancement] Add optional `limit` parameter to `SPLIT_BY_STRING` function 
to control maximum number of splits.
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [x] 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.
       - [x] Yes.   Added optional third parameter limit to SPLIT_BY_STRING 
function. The change is backward compatible; existing two-parameter calls work 
as before.
   
   - Does this need documentation?
       - [ ] No.
       - [x] Yes. Will create documentation PR to update function reference.
   
   ### 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]

Reply via email to