You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "andygrove (via GitHub)" <gi...@apache.org> on 2026/05/28 17:34:46 UTC

[I] [Bug] replace returns wrong result for empty-string search [datafusion-comet]

andygrove opened a new issue, #4497:
URL: https://github.com/apache/datafusion-comet/issues/4497

   ## Describe the bug
   
   `replace(str, search, replacement)` diverges from Spark when `search` is the empty literal string. Spark returns `str` unchanged (short-circuit on `search.numBytes == 0` in `StringReplace.eval`). Comet delegates to DataFusion's `replace`, which inserts `replacement` between every character and at both boundaries.
   
   ## How to Reproduce
   
   ```sql
   SELECT replace('hello', '', 'x');
   ```
   
   | Engine | Result |
   | --- | --- |
   | Spark | `hello` |
   | Comet (DataFusion) | `xhxexlxlxox` |
   
   ## Additional context
   
   Surfaced by the string-expressions audit (#4461) follow-up. Issue #3344 covered the same divergence but the body had the expected/actual values swapped, leading to it being closed as already-fixed. This issue restates the divergence with the correct direction.
   
   Workaround: the `audit-comet-expression` follow-up marks `replace` as `Incompatible(Some(reason))` only when `searchExpr` is a literal empty string, so the dispatcher falls back to Spark for that specific case unless the user opts in with `spark.comet.expression.StringReplace.allowIncompatible=true`.


-- 
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.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: [I] [Bug] replace returns wrong result for empty-string search [datafusion-comet]

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove closed issue #4497: [Bug] replace returns wrong result for empty-string search
URL: https://github.com/apache/datafusion-comet/issues/4497


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