Thanks. To try and illustrate a little more -  I have users creating ad-hoc
SQL that provides the data they want, but may not be written optimally.
 I'd like to be able to use Calcite in some form to accept a SQL string
from them and return an improved / optimised SQL string.

For my use case,  calcite can have a live connection to the DBMS to get
schema information and and other metadata it needs for optimization
purposes.   However I would like for it to avoid the normal final step of
actually executing the user's query to fetch data.

Hopefully that explains the goal / context better,  but if not please let
me know.

Regards

Andrew

On Thu, 18 Apr 2019, 05:34 Yuzhao Chen, <[email protected]> wrote:

> Andrew, I’m not very sure if I got your idea right.
>
> Do you want a promoted `Sql` compared  to the original ? Then you should
> transform Calcite’s RelNodes tree to sql, but Calcite do not support this
> yet, The SqlNode unparse to sql is actually supported.
>
> It is not that equivalent for RelNodes tree and sql text, e.g. How to
> describe a SemiJoin in sql ? Another question is the pure text to data
> source will actually have another planning phrase, we can not make sure
> this plan is the best and efficient.
>
> Best,
> Danny Chan
> 在 2019年4月18日 +0800 AM5:22,Andrew O <[email protected]>,写道:
> > I'm interested in using Calcite in a "no execute" mode that would
> > effectively return the optimized SQL but not actually execute it. The
> > intention would be to leverage a) the query planning / optimization b)
> the
> > support for outputting different SQL dialects.
> >
> > I can see some Tests (e.g. JdbcTest.java) use CalciteAssert and that it
> has
> > a check "planHasSql" function. This seems to use a Hook to capture the
> sql
> > as part of the execution flow, so is not quite what I'm trying to do.
> >
> > I appreciate Calcite attempts to provide abstractions for different
> > execution layers to allow cross adaptor function, so in theory a single
> SQL
> > statement may not always be available. However in my context I know it
> > will be executing only against a single JDBC source and not other types.
> >
> > Is there any suggested / recommended approaches to this, or pointers to
> > bits of code to look at?
> >
> > Thanks in advance
> >
> > Andrew
>

Reply via email to