You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Ken <na...@gmail.com> on 2015/09/28 13:28:48 UTC

How to use SqlStdOperatorTable.IN in RelBuilder

Hi,

Can anyone tell me how to use the *IN* operator when building a Relation
Node?

builder.filter(
                builder.call(SqlStdOperatorTable.IN, builder.field("id"),
builder.literal(0), builder.literal(2)));

I try to execute this RelNode but always got error
message: java.lang.RuntimeException: cannot translate call IN($t0, $t6, $t8)

There are no sample test code for the IN operator. Anyway knows?

Thanks
Ken

Re: How to use SqlStdOperatorTable.IN in RelBuilder

Posted by Ken <na...@gmail.com>.
Yes, we are using the OR operation instead now. Anyway, thanks for logging
this, Julian.

Ken

On Mon, Sep 28, 2015 at 9:34 PM, Julian Hyde <jh...@apache.org> wrote:

> Calcite doesn’t support IN in relational expressions, only in ASTs. You’ll
> have to manually rewrite to
>
> builder.filter(
>   builder.or(
>     builder.equals(builder.field(“id”), builder.literal(0)),
>     builder.equals(builder.field(“id”), builder.literal(2))))
>
> We should add RelBuilder.in(RexNode seek, RexNode terms…) as syntactic
> sugar. I have logged https://issues.apache.org/jira/browse/CALCITE-901 <
> https://issues.apache.org/jira/browse/CALCITE-901>.
>
> Julian
>
>
> > On Sep 28, 2015, at 4:28 AM, Ken <na...@gmail.com> wrote:
> >
> > Hi,
> >
> > Can anyone tell me how to use the *IN* operator when building a Relation
> > Node?
> >
> > builder.filter(
> >                builder.call(SqlStdOperatorTable.IN, builder.field("id"),
> > builder.literal(0), builder.literal(2)));
> >
> > I try to execute this RelNode but always got error
> > message: java.lang.RuntimeException: cannot translate call IN($t0, $t6,
> $t8)
> >
> > There are no sample test code for the IN operator. Anyway knows?
> >
> > Thanks
> > Ken
>
>

Re: How to use SqlStdOperatorTable.IN in RelBuilder

Posted by Julian Hyde <jh...@apache.org>.
Calcite doesn’t support IN in relational expressions, only in ASTs. You’ll have to manually rewrite to

builder.filter(
  builder.or(
    builder.equals(builder.field(“id”), builder.literal(0)),
    builder.equals(builder.field(“id”), builder.literal(2))))

We should add RelBuilder.in(RexNode seek, RexNode terms…) as syntactic sugar. I have logged https://issues.apache.org/jira/browse/CALCITE-901 <https://issues.apache.org/jira/browse/CALCITE-901>.

Julian


> On Sep 28, 2015, at 4:28 AM, Ken <na...@gmail.com> wrote:
> 
> Hi,
> 
> Can anyone tell me how to use the *IN* operator when building a Relation
> Node?
> 
> builder.filter(
>                builder.call(SqlStdOperatorTable.IN, builder.field("id"),
> builder.literal(0), builder.literal(2)));
> 
> I try to execute this RelNode but always got error
> message: java.lang.RuntimeException: cannot translate call IN($t0, $t6, $t8)
> 
> There are no sample test code for the IN operator. Anyway knows?
> 
> Thanks
> Ken