You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Alexey Roytman <al...@oracle.com> on 2017/11/14 11:59:18 UTC

getting original SQL text

Hello,
can anyone point point me to how do I get the original (non-parsed and 
non-beautified with backticks) SQL SELECT statement when I'm in:
1. ProjectableFilterableTable.scan()
2. TranslatableTable.toRel()
calls? Thank you.
- Alexey.


Re: getting original SQL text

Posted by Julian Hyde <jh...@apache.org>.
There may not be an “original” SQL - the table may have been created by pushing down filters and projects, and so forth. In any case, we do not keep the SQL when we convert SqlNode to RelNode.

You may have some luck looking at what comes out of SqlToRelConverter. Maybe at that point there is enough information to link a TableScan to the SqlIdentifier that it was created from. The SqlIdentifier, as a SqlNode, knows the region (start row and column to end row and column) in the source text.

Also, if your table scan is a JdbcTableScan then you could use JdbcImplementor to generate SQL in whatever dialect you like (with or without back-ticks). But it wouldn’t be the original SQL.

Julian


> On Nov 14, 2017, at 3:59 AM, Alexey Roytman <al...@oracle.com> wrote:
> 
> Hello,
> can anyone point point me to how do I get the original (non-parsed and non-beautified with backticks) SQL SELECT statement when I'm in:
> 1. ProjectableFilterableTable.scan()
> 2. TranslatableTable.toRel()
> calls? Thank you.
> - Alexey.
>