You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Hartman, Trevor" <th...@ebay.com> on 2015/03/16 21:45:48 UTC

Accessing Calcite internals in test cases

So far I have been testing my Calcite adapter by running queries against a CalciteConnection and checking the results. Is it possible to run a query in such a way that I could access the instances of the expression tree, and get at properties of each node? e.g. access the `condition` property of a Filter and the `getProjects` method of a Project.

Trevor

Re: Accessing Calcite internals in test cases

Posted by Julian Hyde <jh...@apache.org>.
There's always a way. :)

Take a look at the APIs in Frameworks. They give you control over the
steps of query preparation - parse, validate, plan - rather than it
being under the control of a JDBC driver.

Also take a look at "enum Hook" and see where its members are used.
For example, Hook.CONVERTED is a hook (a list of handler functions)
that is called with the RelNode tree that comes out of
SqlToRelConverter.

Hook is subject to change without notice, and should only be used for
testing and debugging, not during production. Obviously.

CalciteAssert.AssertQuery.withHook gives a nice mechanism to set a
hook in the current thread, do some work, and remove the hook
afterwards.

Julian


On Mon, Mar 16, 2015 at 1:45 PM, Hartman, Trevor <th...@ebay.com> wrote:
> So far I have been testing my Calcite adapter by running queries against a CalciteConnection and checking the results. Is it possible to run a query in such a way that I could access the instances of the expression tree, and get at properties of each node? e.g. access the `condition` property of a Filter and the `getProjects` method of a Project.
>
> Trevor