You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Anoop Johnson <an...@gmail.com> on 2016/08/23 17:09:41 UTC

Transforming the parse tree using a Hook

Hello Everyone -

I need to transform a the parse tree before it will be executed. I could
use the Hook.PARSE_TREE mechanism to add an observer and inspect the parse
tree, but is there a way for the observer to modify the SqlNode?

Thanks,
Anoop

Re: Transforming the parse tree using a Hook

Posted by Julian Hyde <jh...@apache.org>.
Hooks are intended mainly for tracing/monitoring applications, i.e. read-only. If you want to modify the query preparation life cycle (parse, validate, optimize) then you should probably sub-class org.apache.calcite.prepare.Prepare to use a different parser. See Driver.createPrepareFactory.

Also, think carefully whether you really want to modify the SqlNode tree, because of SQL’s complicated rules on how table and column names are resolved. It is usually safer to modify the RelNode tree.

Julian



> On Aug 23, 2016, at 10:09 AM, Anoop Johnson <an...@gmail.com> wrote:
> 
> Hello Everyone -
> 
> I need to transform a the parse tree before it will be executed. I could
> use the Hook.PARSE_TREE mechanism to add an observer and inspect the parse
> tree, but is there a way for the observer to modify the SqlNode?
> 
> Thanks,
> Anoop