Skip to content

feat: implement is_null method for DictionaryArray and TypedDictionar… #7608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

kosiew
Copy link
Contributor

@kosiew kosiew commented Jun 5, 2025

Which issue does this PR close?

Closes #7607.

Rationale for this change

Previously, the is_null method on DictionaryArray only considered nulls in the keys buffer, which could result in inaccurate null reporting when the dictionary values themselves contained nulls. This change ensures that nulls are correctly propagated by also checking the referenced value in the dictionary array.

Accurately reflecting null semantics is essential for correctness in downstream operations such as filtering, joins, and aggregations.

What changes are included in this PR?

  • Implemented a custom is_null method in DictionaryArray that checks both the key and its referenced value.
  • Implemented a corresponding override in TypedDictionaryArray to delegate to the dictionary's is_null.
  • Added a unit test test_is_null_considers_dictionary_values to verify the combined null behavior in both raw and typed dictionary arrays.

Are there any user-facing changes?

Yes, this changes the behavior of is_null for DictionaryArray and TypedDictionaryArray. Users relying on the previous behavior (which only checked key nulls) may observe different results if dictionary values contain nulls.

This aligns the behavior more closely with expected null propagation semantics but should be considered a behavioral fix that might impact some logic in downstream code.

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jun 5, 2025
@kosiew kosiew marked this pull request as draft June 5, 2025 08:34
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

This will regress performance potentially significantly for the common case where there are no null values in the values array. Ultimately our hands are tied here, ultimately the arrow specification does not encode nullability in a manner that neatly maps to logical concepts. Array::logical_nulls is the compromise we came up with, and allows amortising the logical null computation over multiple values.

@kosiew
Copy link
Contributor Author

kosiew commented Jun 5, 2025

Thank you @tustvold for your explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DictionaryArray::is_null does not consider null values in the dictionary value array
2 participants