You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Shashwat Kumar <sh...@gmail.com> on 2018/10/30 02:02:07 UTC

Access SELECT and WHERE Clause column names in SQL Query

Hi,

My backend gets the SQL query from the user. I want to modify SQL statement
before executing it. How can I get the SELECT column names and WHERE column
names from the SQL query.
I know that probably SqlParser is to be used but I am not able to make it
work. Please advise.

-- 
Regards
Shashwat Kumar

Re: Access SELECT and WHERE Clause column names in SQL Query

Posted by Shashwat Kumar <sh...@gmail.com>.
Thank you Michael.

I tried SqlVisitor only earlier but was not able to make that work. Got it
now and able to fetch required details from the query.

On Tue, Oct 30, 2018 at 7:00 PM Michael Mior <mm...@apache.org> wrote:

> What have you tried? You should be able to build a SqlParser and call the
> parseQuery method. With the resulting SqlNode, you may want to try
> implementing the SqlVisitor interface to get the data you need.
>
> --
> Michael Mior
> mmior@apache.org
>
>
> Le mar. 30 oct. 2018 à 02:02, Shashwat Kumar <sh...@gmail.com> a
> écrit :
>
> > Hi,
> >
> > My backend gets the SQL query from the user. I want to modify SQL
> statement
> > before executing it. How can I get the SELECT column names and WHERE
> column
> > names from the SQL query.
> > I know that probably SqlParser is to be used but I am not able to make it
> > work. Please advise.
> >
> > --
> > Regards
> > Shashwat Kumar
> >
>


-- 
Regards
Shashwat Kumar

Re: Access SELECT and WHERE Clause column names in SQL Query

Posted by Michael Mior <mm...@apache.org>.
What have you tried? You should be able to build a SqlParser and call the
parseQuery method. With the resulting SqlNode, you may want to try
implementing the SqlVisitor interface to get the data you need.

--
Michael Mior
mmior@apache.org


Le mar. 30 oct. 2018 à 02:02, Shashwat Kumar <sh...@gmail.com> a
écrit :

> Hi,
>
> My backend gets the SQL query from the user. I want to modify SQL statement
> before executing it. How can I get the SELECT column names and WHERE column
> names from the SQL query.
> I know that probably SqlParser is to be used but I am not able to make it
> work. Please advise.
>
> --
> Regards
> Shashwat Kumar
>