Skip to content

fix(regexp_replace): validate IsString on unwrapped union values#6898

Open
SAY-5 wants to merge 1 commit intobrimdata:mainfrom
SAY-5:fix/regexp_replace-union-string-6892
Open

fix(regexp_replace): validate IsString on unwrapped union values#6898
SAY-5 wants to merge 1 commit intobrimdata:mainfrom
SAY-5:fix/regexp_replace-union-string-6892

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 2, 2026

Closes #6892.

regexp_replace() already unwraps each arg with .Under() to handle
union types, but the IsString() check was performed on the original
wrapper rather than the unwrapped value. For inputs typed as
union(string|null), the wrapper carries the union type
(IsString()==false) even when the underlying value is a string, so
the call was rejected with regexp_replace: string arg required.

This patch validates IsString() on sVal/reVal/newVal directly,
so the function accepts string values whether they arrive as plain
strings or as the string member of a union. The vector runtime
unwraps before evaluation, which is why the same query worked under
-vam.

Repro (from #6892)

Before:

$ echo '"hello world"::(string|null)' | super -sam -c "values regexp_replace(this, 'hello', 'goodbye')" -
error({message:"regexp_replace: string arg required",on:"hello world"::(string|null)})

After:

$ echo '"hello world"::(string|null)' | super -sam -c "values regexp_replace(this, 'hello', 'goodbye')" -
"goodbye world"

…ort unions

Closes brimdata#6892.

regexp_replace() unwraps each arg with .Under() to handle union types,
but the IsString() check was performed on the original wrapper instead
of the unwrapped values. For inputs typed as union(string|null), the
wrapper carries the union type (IsString()==false) even when the
underlying value is a string, so the function rejected them with
'string arg required'.

Validate IsString() on sVal/reVal/newVal directly. The vector runtime
already unwraps before evaluation, which is why it worked there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

regexp_replace rejects union in sequential runtime

1 participant