You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "gferrate (via GitHub)" <gi...@apache.org> on 2026/02/25 09:59:11 UTC

[PR] fix: handle empty delimiter in split_part (closes #20503) [datafusion]

gferrate opened a new pull request, #20542:
URL: https://github.com/apache/datafusion/pull/20542

   ## Which issue does this PR close?
   
   - Closes #20503 
   
   ## Rationale for this change
   
   `split_part` did not handle empty delimiters in a PostgreSQL-compatible way (`split("")` in Rust creates leading/trailing empty fields).
   This could return unexpected results for positions like `1` / `-1` and out-of-range values.
   This PR aligns behavior with Postgres semantics for empty delimiters.
   
   ## What changes are included in this PR?
   
   Small change in how we treat the 1, -1
   
   ## Are these changes tested?
   
   Indeed!
   
   ## Are there any user-facing changes?
   
   Yes, behavior is now more consistent with PostgreSQL for `split_part(str, '', n)`.
   No API changes.
   
   


-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: handle empty delimiter in split_part (closes #20503) [datafusion]

Posted by "gferrate (via GitHub)" <gi...@apache.org>.
gferrate commented on code in PR #20542:
URL: https://github.com/apache/datafusion/pull/20542#discussion_r2852676223


##########
datafusion/functions/src/string/split_part.rs:
##########
@@ -341,6 +356,117 @@ mod tests {
             Utf8,
             StringArray
         );
+        // Edge cases with delimiters

Review Comment:
   Added!



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] fix: handle empty delimiter in split_part (closes #20503) [datafusion]

Posted by "LiaCastaneda (via GitHub)" <gi...@apache.org>.
LiaCastaneda commented on code in PR #20542:
URL: https://github.com/apache/datafusion/pull/20542#discussion_r2852051394


##########
datafusion/functions/src/string/split_part.rs:
##########
@@ -341,6 +356,117 @@ mod tests {
             Utf8,
             StringArray
         );
+        // Edge cases with delimiters

Review Comment:
   wdyt about adding a couple of test cases for these edge cases in the [sqllogic tests](https://github.com/apache/datafusion/blob/e937cadbcceff6a42bee2c5fc8d03068fa0eb30c/datafusion/sqllogictest/test_files/string/string_literal.slt#L854) too?



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org