[CALCITE-4777]Casting from DECIMAL to BOOLEAN throws an exception
According to the discussion in [calcite-4777], casting from decimal to boolean is invalid, and an exception like "Cast function cannot convert value of type DECIMAL(2,1) to type BOOLEAN" will be thrown in the period of validating. This pr changes:
- remove the coerce rule from decimal to boolean, which will lead to throw a conversion exception and let users know this is an invalid conversion.
- add some test cases in SqlOperatorBaseTest.
- change the reference.md to say this invalid conversion
LGTM @xuyangzhong the PR looks in a good shape, could you please squash commits into a single one so that we can merge it shortly?
LGTM @xuyangzhong the PR looks in a good shape, could you please squash commits into a single one so that we can merge it shortly?
@rubenada As discussed in Jira(According to my understanding of the comments). The SQL:
select cast(1 as boolean)
select cast(0 as boolean)
is also invalid.
@NobiGo my understanding was that casting decimal (and float, real, double) into boolean will be forbidden (implemented by this PR); but casting integer types into boolean is (and will continue being) allowed. A different issue is that currently casting integer into boolean always returns false (instead of zero->false; non-zero->true), but there was another ticket to deal with this problem: CALCITE-4782. Let us clarify this in the Jira ticket.
@rubenada done