Skip to content

Native replace() returns wrong result for empty-string search #3344

Closed

Description

@andygrove

Description

Comet's native replace() function returns incorrect results when the search string is empty.

Spark behavior: replace('hello', '', 'x') returns xhxexlxlxox (inserts replacement between every character and at boundaries).

Comet behavior: returns hello (no replacement).

How to Reproduce

SELECT replace('hello', '', 'x');

Expected: xhxexlxlxox
Actual (Comet): hello

Expected Behavior

Comet should match Spark's semantics for empty-string search in replace().

Activity

  1. wattt3 commented on Feb 4, 2026

    @wattt3

    take

  2. andygrove commented on Feb 6, 2026

    @andygrove
    MemberAuthor

    @wattt3 apologies - this issue seems to be invalid. It is based on the behavior of Java's string replace method and not the Spark implementation

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions