Skip to content

Conversation

@Eshaan-byte
Copy link

Fixes #19174

This PR adds custom nullability handling for the Spark ILIKE function. Previously, the function was using the default is_nullable which always returns true, which is not correct.

Changes

  • Implemented return_field_from_args() to handle custom nullability logic
    • The result is nullable if any of the input arguments is nullable
    • This matches Spark's behavior where ILIKE(NULL, pattern) or ILIKE(str, NULL) returns NULL
  • Updated return_type() to use internal_err! pattern to enforce use of return_field_from_args
  • Added comprehensive nullability tests covering all combinations:
    • Non-nullable when both inputs are non-nullable
    • Nullable when first input is nullable
    • Nullable when second input is nullable
    • Nullable when both inputs are nullable

Test Plan

All existing tests pass:
running 2 tests test function::string::ilike::tests::test_ilike_nullability ... ok test function::string::ilike::tests::test_ilike_invoke ... ok test result: ok. 2 passed; 0 failed; 0 ignored

The implementation follows the same pattern used by other Spark functions in the codebase (like shuffle and array)

The ILIKE function was using the default is_nullable which always
returns true. This fix implements custom nullability logic where the
result is nullable if any of the input arguments is nullable.

This matches Spark's behavior where ILIKE(NULL, pattern) or
ILIKE(str, NULL) returns NULL.

Changes:
- Implemented return_field_from_args() to handle custom nullability
- Updated return_type() to use internal_err! pattern
- Added comprehensive nullability tests

Fixes apache#19174
@github-actions github-actions bot added the spark label Dec 8, 2025
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @Eshaan-byte the PR makes sense IMO

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spark ilike need to have custom nullability

2 participants