vera-rubin opened a new pull request, #26450:
URL: https://github.com/apache/datafusion/pull/26450

   ## Which issue does this PR close?
   
   There's no issue for this yet, so this PR is also the bug report.
   
   ## Rationale for this change
   
   When a multi-character delimiter can overlap itself, negative `split_part` 
positions pick different fields than positive ones. Splitting `foo:::bar` on 
`::` gives the fields `foo` and `:bar`, so position 2 returns `:bar`. But 
position -1 returns `bar` and -2 returns `foo:`. The docs say negative values 
count backward from the end, so -1 should also return `:bar`.
   
   Tested on: main at `484183dc34ea565190d9cd4a66db6d24789f95d0`.
   
   ```sql
   SELECT split_part('foo:::bar', '::', 2), split_part('foo:::bar', '::', -1);
   -- :bar | bar
   ```
   
   ## What changes are included in this PR?
   
   For delimiters that can overlap themselves, negative positions now count the 
fields found from the left, while all other delimiters keep the existing 
reverse search.
   
   ## What is the testing strategy for this PR?
   
   We added sqllogictest cases to `expr.slt` that cover scalar and column 
delimiters and Utf8View. They fail on main and pass with this change.
   
   ## Are there any user-facing changes?
   
   Yes, negative positions now return the right field for delimiters like `::` 
or `aba`.
   
   — [ChipLab](https://chiplab.donmakino.com/findings#clab-2026-968)
   


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