Skip to content

Conversation

@lriggs
Copy link
Contributor

@lriggs lriggs commented Jan 27, 2026

…ll strings.

Rationale for this change

Fixes GH-49034.
The binary_string funcion will attempt to allocate 0 bytes of memory, which results in a null ptr being returned and the function interprets that as an error.

What changes are included in this PR?

Add kCanReturnErrors to the function definition to match other string functions.
Move the check for 0 byte length input earlier in the binary_string function to prevent the 0 allocation.
Add a unit test.

Are these changes tested?

Yes, unit and integration testing.

Are there any user-facing changes?

No.

@github-actions
Copy link

⚠️ GitHub issue #49034 has been automatically assigned in GitHub to PR creator.

gdv_int32* out_len) {
if (text_len == 0) {
*out_len = 0;
return "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java version is NullHandling.NULL_IF_NULL
Are we going to return empty string for null? If so - that's inconsistency we can't have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns null, the same as Java.

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jan 27, 2026
Copy link
Contributor

@akravchukdremio akravchukdremio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C++][Gandiva] binary_string can throw an error if input is null

3 participants