Hi There, 
Thanks for your interest in Drill.  Can you please explain a bit more about 
what you're trying to do?  My intiial thought is to use a CASE statement rather 
than a CAST function.  IE:

SELECT ...
(CASE 
   WHEN foo = true THEN 1
   ELSE 0
END)
FROM dfs...

Best,
--C 

> On Feb 26, 2020, at 9:03 AM, Зиновьев Олег <[email protected]> wrote:
> 
> Hello.
> 
> I am confused with the implicit Drill cast rules for BIT data type. According 
> to TypeCastRules.java there is the possibility of conversion between BIT and 
> INT (and other number type), e.g. cast(true as int). However, when trying to 
> perform such a conversion, the error "Missing function implementation: 
> [castBIGINT (BIT-REQUIRED)]" occurs.
> 
> As far as I understand, Drill scans the list of functions for conversion (in 
> my case it is castINT) and tries to find the chain of transformations that is 
> the least expensive. However, since there is no direct BIT -> INT conversion 
> function, it selects the function with the least difference in 
> ResolverTypePrecedence.precedenceMap and tries to add a additional cast for 
> the argument (In my case it is [castINT (BIGINT-REQUIRED), since 
> TypeCastRules.java also allows conversion BIT -> BIGINT). At the time of 
> searching for the argument conversion function, the error mentioned above 
> occurs.
> 
> questions:
> 1) Is it correct that BIT -> Number conversions are allowed in TypeCastRules?
> 2) Was the conversion supposed to be done through TinyInt? However, for this 
> type I could not find the conversion functions to other types of numbers.
> 3) the inability to convert BIT to number is an error? Or is this the correct 
> behavior?

Reply via email to