It works for me.
public static void main(String[] args) throws SqlParseException {
try {
SqlParser parser = SqlParser.create("SUM(t1.amount)/COUNT(t1)");
SqlNode sqlNode = parser.parseExpression();
} catch (Throwable e) {
e.printStackTrace();
}
}
> On Jan 18, 2018, at 1:44 PM, Nirav Patel <[email protected]> wrote:
>
> Is it possible to just parse sql function expression which is not a
> complete sql syntax.
> e.g. I want to parse expression `SUM(t1.amount)/COUNT(t1)` instead of whole
> sql like "select t1.name, SUM(t1.amount)/COUNT(t1) from mytable t1 group by
> t1.name". I tried
>
> val parser = SqlParser.create("SUM(t1.amount)/COUNT(t1)")
> val sqlNode = parser.parseExpression()
>
> but it fails with parse exception.
>
> Thanks
>
> --
>
>
> [image: What's New with Xactly] <http://www.xactlycorp.com/email-click/>
>
> <https://www.instagram.com/xactlycorp/>
> <https://www.linkedin.com/company/xactly-corporation>
> <https://twitter.com/Xactly> <https://www.facebook.com/XactlyCorp>
> <http://www.youtube.com/xactlycorporation>