lriggs opened a new pull request, #50110:
URL: https://github.com/apache/arrow/pull/50110
### Rationale for this change
Three small, independent bugs in Gandiva's runtime error messages: in two
cases the message misrepresents what actually failed, and in one case a
copy-paste error left the wrong function name in a message.
### What changes are included in this PR?
#### 1. `levenshtein` reported OOM as a length error
[cpp/src/gandiva/precompiled/string_ops.cc:1738-1742](cpp/src/gandiva/precompiled/string_ops.cc#L1738-L1742)
— when `gdv_fn_context_arena_malloc` returned null (i.e. memory allocation
failed), the function set the error to `"String length must be greater than
0"`. The condition is an OOM, not a length issue. Now reports `"LEVENSHTEIN:
could not allocate working memory"`.
#### 2. `levenshtein` length-bound message was off by one
[cpp/src/gandiva/precompiled/string_ops.cc:1702-1708](cpp/src/gandiva/precompiled/string_ops.cc#L1702-L1708)
— the precondition is `in1_len < 0 || in2_len < 0`, which rejects only
negative lengths (zero is valid). The message said `"must be greater than 0"`,
implying zero was rejected too. Corrected to `"LEVENSHTEIN: input lengths must
be non-negative, got <a> and <b>"`, which now also echoes the offending values.
#### 3. `gdv_fn_aes_decrypt` reported the wrong direction
[cpp/src/gandiva/gdv_function_stubs.cc:411](cpp/src/gandiva/gdv_function_stubs.cc#L411)
— inside the AES **decrypt** function, the OOM message said `"Could not
allocate memory for returning aes encrypt cypher text"`. Pure copy-paste from
the sibling encrypt function. Corrected the direction wording.
#### Test updates
[cpp/src/gandiva/precompiled/string_ops_test.cc:1133-1135](cpp/src/gandiva/precompiled/string_ops_test.cc#L1133-L1135)
— the levenshtein test was asserting `HasSubstr("String length must be greater
than 0")`, which was matching the *bug message* — i.e. the test was effectively
verifying the wrong behavior. Updated to assert the corrected message substring.
### Are these changes tested?
```bash
cd cpp/debug
cmake --build . --target gandiva_shared gandiva-precompiled-test
gandiva-internals-test gandiva-projector-test -j4
./debug/gandiva-precompiled-test # 130/130 pass
./debug/gandiva-internals-test # 156/156 pass
./debug/gandiva-projector-test # 218/218 pass
```
### Are there any user-facing changes?
Yes, improved error message accuracy.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]