calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Hyde <jh...@apache.org>
Subject Re: How to parse sql expression to obtain field names
Date Thu, 18 Jan 2018 23:01:31 GMT
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 <npatel@xactlycorp.com> 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>


Mime
View raw message