Skip to content
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

Incorrect and inconsistency handling of NULL values in ScalarValue for ListArray #7968

Closed
viirya opened this issue Oct 29, 2023 · 3 comments · Fixed by #7969
Closed

Incorrect and inconsistency handling of NULL values in ScalarValue for ListArray #7968

viirya opened this issue Oct 29, 2023 · 3 comments · Fixed by #7969
Labels
bug Something isn't working

Comments

@viirya
Copy link
Member

viirya commented Oct 29, 2023

Describe the bug

  • try_from_array produces inconsistent ScalarValue::List for valid and non-valid (NULL) values

    For NULL value in ListArray, try_from_array produces ScalarValue::List(new_null_array(&DataType::Null, 0)) which isn't consistent with the case when invoking try_from_array on valid value of ListArray.

    Fro valid value, try_from_array produces a ListArray containing single element of the specified value in provided ListArray. For example, if input array is ListArray[[1, 2, 3], [4, 5, 6]]], try_from_array(arr, 0) will produce ListArray[[1, 2, 3]].

    For NULL value, try_from_array currently produces a null array ofDataType::Null type. Not only it is not a ListArray, the data type is not the element type of provided ListArray too.

  • ScalarValue::List has same value and datatype for ListArray and nested ListArray's NULL values
    NULL values from ListArray and nested ListArray are the same ScalarValue::List(new_null_array(&DataType::Null, 0)). So their datatypes are the same. This is also incorrect.

To Reproduce

No response

Expected behavior

No response

Additional context

No response

@alamb
Copy link
Contributor

alamb commented Oct 29, 2023

Thank you @viirya -- the way ARRAY datatypes handle null now is non ideal -- they use DataType::Null inconsistenty rather than DataType::List with an appropriate Null literal -- perhaps this is related to #7142

cc @jayzhan211 -- maybe #7142 would be a good simplification to try and work on in the context of moving DataFusion array support forward

@jayzhan211
Copy link
Contributor

jayzhan211 commented Oct 29, 2023

cc @jayzhan211 -- maybe #7142 would be a good simplification to try and work on in the context of moving DataFusion array support forward

Great, I was thinking of it too.

@viirya
Copy link
Member Author

viirya commented Oct 29, 2023

No, this is another issue, I think.

This issue is due to incorrect and inconsistency handling of NULL value on ScalarValue::List. It doesn't involve array functions. I added some description to this issue. Please also see the proposed PR.

@viirya viirya changed the title try_from_array returns incorrect value for NULL value in ListArray Incorrect handling of NULL values in ScalarValue for ListArray Oct 29, 2023
@viirya viirya changed the title Incorrect handling of NULL values in ScalarValue for ListArray Incorrect and inconsistency handling of NULL values in ScalarValue for ListArray Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants