SqlShuttle is probably the easiest thing, and it works for simple
cases. If it works for you, use it.

There are cases where you need to know the type of the columns being
referenced, or to deal with ambiguous references, or to make
structural changes to the query. For these complex cases, people
translate to relational algebra (RelNode) and transform the algebra
expression. This is where Calcite really excels.

Julian

On Wed, Jan 6, 2021 at 6:44 PM JiaTao Tao <[email protected]> wrote:
>
> Hi
> IMO visitor is fine.
>
> Regards!
>
> Aron Tao
>
>
> kant kodali <[email protected]> 于2021年1月6日周三 下午8:11写道:
>
> > Hi,
> >
> > Thanks, that works. Got another question.
> >
> > Lets say, I want to expose a model to users that contains a bunch of fields
> > and each field has a corresponding database column. now a user sends me a
> > query which contains some fields and I want to replace them with columns.
> > Is there any inbuilt way in calcite to do this rather than me implementing
> > a visitor? If so, any example?
> >
> > I already did it with a SqlShuttle visitor and it works but want to know if
> > there is an easier and out of the box way to do this?
> >
> >
> > Thanks.
> >
> >
> > On Tue, Jan 5, 2021 at 6:43 PM JiaTao Tao <[email protected]> wrote:
> >
> > > Hi
> > > Try this:  SqlParser.create(expr).parseExpression();
> > >
> > > Regards!
> > >
> > > Aron Tao
> > >
> > >
> > > kant kodali <[email protected]> 于2021年1月5日周二 上午9:34写道:
> > >
> > > > Hi All,
> > > >
> > > > is there a way to parse only the where clause using calcite (any sample
> > > > code)? meaning,  for example, assume the input is something like
> > > >
> > > > view1.col1 = value1 or view2.col2 = value2 and view3.col3 = value3
> > > >
> > > > I want to parse this expression and replace view1.col1 with a,
> > view2.col2
> > > > with b and view3.col3 = c such that the output should be
> > > >
> > > > a = value1 or b = value2 and c = value3.
> > > >
> > > > This is just an example but I can get more complex boolean expressions
> > as
> > > > input.
> > > >
> > > > Thanks!
> > > >
> > >
> >

Reply via email to