Reputation: 197
I'm trying to do a SQL transform with Apache Beam using Calcite SQL syntax. I'm doing an int to boolean cast. My sql looks like this:
,CASE WHEN cast(IsService as BOOLEAN) THEN CASE WHEN IsEligible THEN 1 ELSE 0 END ELSE NULL END AS Reported
Where IsService is an indicator int and IsEligible is a boolean.
According to the documentation an explicit cast from int to boolean is fine. However, I get the below error when I run the pipeline:
Caused by: org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.sql.validate.SqlValidatorException: Cast function cannot convert value of type INTEGER to type BOOLEAN
Can anyone explain why I'm getting the error?
Upvotes: 0
Views: 452
Reputation: 6023
To solve your problem immediately, you could use IsService > 0
instead of CAST
. In my opinion, it is even more clear what the conversion is. I am not a fan of relying on "falsey" values.
Upvotes: 1