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

angles function not support NULL input like MySQL #2844

Closed
pymongo opened this issue Nov 17, 2021 · 4 comments · Fixed by #2904
Closed

angles function not support NULL input like MySQL #2844

pymongo opened this issue Nov 17, 2021 · 4 comments · Fixed by #2904
Assignees
Labels
C-improvement Category: improvement community-take

Comments

@pymongo
Copy link
Contributor

pymongo commented Nov 17, 2021

Summary

databend:

MySQL [(none)]> SELECT RADIANS(NULL);
ERROR 1105 (HY000): Code: 7, displayText = Expected numeric, but got Null.

MySQL:

MariaDB [(none)]> SELECT RADIANS(NULL);
+---------------+
| RADIANS(NULL) |
+---------------+
|          NULL |
+---------------+

How to reproduce

SELECT RADIANS(NULL);

Additional context

https://github.com/datafuselabs/databend/blob/a4781bf3cff6286caf30200eddbe9f3648ad9e06/common/functions/src/scalars/maths/angle.rs#L66

angle function source code not support NULL input

@flaneur2020
Copy link
Member

flaneur2020 commented Nov 17, 2021

besides the type check in the return_value() function, here'd raise an error on casting a NULL array to a float64 array:

https://github.com/datafuselabs/databend/blob/a4781bf3cff6286caf30200eddbe9f3648ad9e06/common/functions/src/scalars/maths/angle.rs#L84

casting a NULL array to a float64 array is legal in the arrow semantics, because all the array element in arrow are nullable

but the arrow2 version we're using hasn't include the NULL casting logic yet, after cherry-picking this PR from arrow2 jorgecarleitao/arrow2#589 , this casting error could be suppressed.

@BohuTANG
Copy link
Member

besides the type check in the return_value() function, here'd raise an error on casting a NULL array to a float64 array:

https://github.com/datafuselabs/databend/blob/a4781bf3cff6286caf30200eddbe9f3648ad9e06/common/functions/src/scalars/maths/angle.rs#L84

casting a NULL array to a float64 array is legal in the arrow semantics, because all the array element in arrow are nullable

but the arrow2 version we're using hasn't include the NULL casting logic yet, after cherry-picking this PR from arrow2 jorgecarleitao/arrow2#589 , this casting error could be suppressed.

https://github.com/datafuse-extras/arrow2 has updated with the upstream

@sundy-li
Copy link
Member

Maybe all of the functions we should support DataType::Null ?

@pymongo pymongo removed their assignment Nov 17, 2021
@BohuTANG BohuTANG added the C-improvement Category: improvement label Nov 18, 2021
@flaneur2020
Copy link
Member

flaneur2020 commented Nov 18, 2021

Maybe all of the functions we should support DataType::Null ?

I think so 🤔 , to keep th null semantics same as mysql

@sundy-li sundy-li self-assigned this Nov 18, 2021
@pymongo pymongo removed their assignment Nov 19, 2021
BohuTANG added a commit that referenced this issue Nov 20, 2021
angles function not support NULL input like MySQL #2844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-improvement Category: improvement community-take
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants