You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Gavin Nicol <gt...@fastmail.com> on 2021/11/17 01:06:40 UTC

binding of boolean literals in SQL

I'm writing a FilterableTable implementation and so far all is well. When handling more complex filters I've come across the need to pass in a boolean flag via a filter clause, something like:

     select "foo" from "bar" where "clean"=true and "id"='1234'

This results in a filter like: AND(CAST($2):BOOLEAN, =(CAST($0):VARCHAR, '1234')), and I'm trying to figure out how to get to the actual value used for the boolean. The operand in this case is a RexInputRef from which I can get to the RelDataTypeField but I can't find the literal anywhere. Any guidance here?

Re: binding of boolean literals in SQL

Posted by Julian Hyde <jh...@gmail.com>.
It’s possible, and I would think desirable, to simplify

  “clean” = true

and for that matter

  “clean” is true

to

  “clean”

and based on your experiments it looks as if we do it already.  

Julian

> On Nov 16, 2021, at 18:06, Gavin Nicol <gt...@fastmail.com> wrote:
> 
> I'm writing a FilterableTable implementation and so far all is well. When handling more complex filters I've come across the need to pass in a boolean flag via a filter clause, something like:
> 
>     select "foo" from "bar" where "clean"=true and "id"='1234'
> 
> This results in a filter like: AND(CAST($2):BOOLEAN, =(CAST($0):VARCHAR, '1234')), and I'm trying to figure out how to get to the actual value used for the boolean. The operand in this case is a RexInputRef from which I can get to the RelDataTypeField but I can't find the literal anywhere. Any guidance here?