You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/16 10:31:31 UTC
[GitHub] [arrow-datafusion] metesynnada opened a new issue, #3511: Comparison of different ScalarValue types produces the silent errors
metesynnada opened a new issue, #3511:
URL: https://github.com/apache/arrow-datafusion/issues/3511
**Describe the bug**
`PartialOrd` implementation of `ScalarValue` types gives `None` for different types and it is automatically cast to `false`. I think this is the wrong behavior and introduces silent errors.
**To Reproduce**
Below test code shows the error
```rust
fn ord_diff_type() {
assert_eq!(
true,
(ScalarValue::Float32(Some(2.0)) < ScalarValue::Int32(Some(3)))
);
}
```
**Expected behavior**
I expected comparison to be true, however comparison `(ScalarValue::Float32(Some(2.0)) < ScalarValue::Int32(Some(3)))` returns `false`. Hence assertion fails. I think returning `false` here is misleading. This comparison either should produce an error or return `true`. If we do the comparison below it works as expected., since they have the same type
```rust
fn ord_same_type() {
assert_eq!(
true,
(ScalarValue::Int32(Some(2))<
ScalarValue::Int32(Some(3)))
);
}
```
**Additional context**
I think casting the left or right side of the comparison to the larger type would solve the problem. The relevant section of the code is below
https://github.com/apache/arrow-datafusion/blob/66dd253d2e0cdd00c8d3611f2ca470b9cde48abc/datafusion/common/src/scalar.rs#L196
--
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: github-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Comparison of different ScalarValue types produces the silent errors [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on issue #3511:
URL: https://github.com/apache/datafusion/issues/3511#issuecomment-3704927391
I think this is working as intended. I don't see how we can return an error for comparison like this, and introducing coercion inside comparison is likely to be complex not to mention we'd still have cases where it doesn't make sense (e.g. compare struct to integer).
I'll close this as unplanned unless there is a strong desire for it.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
[GitHub] [arrow-datafusion] HaoYang670 commented on issue #3511: Comparison of different ScalarValue types produces the silent errors
Posted by GitBox <gi...@apache.org>.
HaoYang670 commented on issue #3511:
URL: https://github.com/apache/arrow-datafusion/issues/3511#issuecomment-1303081680
> This comparison either should produce an error or return true.
I prefer returning an error because the `casting` should have been done in the `type_coercion` stage.
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Comparison of different ScalarValue types produces the silent errors [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed issue #3511: Comparison of different ScalarValue types produces the silent errors
URL: https://github.com/apache/datafusion/issues/3511
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org