@Test public void groupBy(){ long now=System.currentTimeMillis(); String sql="select max(name) as max_name,avg(height) as avg_height,avg(name) as avg_name,min(name) as min_name from student group by name,age,height"; ElasticSql2DslParser parser=new ElasticSql2DslParser(); ElasticSqlParseResult parseResult = parser.parse(sql); System.out.println(parseResult.toPrettyDsl(parseResult.getSearchRequest())); System.out.println(System.currentTimeMillis()-now); }
public ElasticSqlParseResult parse(String sql) throws ElasticSql2DslException{ Walker walker=new Walker(sql); ElasticsearchParser.SqlContext sqlContext = walker.buildAntlrTree(); ElasticDslContext elasticDslContext=new ElasticDslContext(sqlContext); for(QueryParser parser:buildSqlParserChain()){ parser.parse(elasticDslContext); } return elasticDslContext.getParseResult(); }
ElasticSql2DslParser { public ElasticSqlParseResult parse(String sql) throws ElasticSql2DslException{ Walker walker=new Walker(sql); ElasticsearchParser.SqlContext sqlContext = walker.buildAntlrTree(); ElasticDslContext elasticDslContext=new ElasticDslContext(sqlContext); for(QueryParser parser:buildSqlParserChain()){ parser.parse(elasticDslContext); } return elasticDslContext.getParseResult(); } }
ElasticSql2DslParser { public ElasticSqlParseResult parse(String sql) throws ElasticSql2DslException{ Walker walker=new Walker(sql); ElasticsearchParser.SqlContext sqlContext = walker.buildAntlrTree(); ElasticDslContext elasticDslContext=new ElasticDslContext(sqlContext); for(QueryParser parser:buildSqlParserChain()){ parser.parse(elasticDslContext); } return elasticDslContext.getParseResult(); }  }
ElasticSql2DslParser { public ElasticSqlParseResult parse(String sql) throws ElasticSql2DslException{ Walker walker=new Walker(sql); ElasticsearchParser.SqlContext sqlContext = walker.buildAntlrTree(); ElasticDslContext elasticDslContext=new ElasticDslContext(sqlContext); for(QueryParser parser:buildSqlParserChain()){ parser.parse(elasticDslContext); } return elasticDslContext.getParseResult(); }  ElasticSqlParseResult parse(String sql); }
ElasticSql2DslParser { public ElasticSqlParseResult parse(String sql) throws ElasticSql2DslException{ Walker walker=new Walker(sql); ElasticsearchParser.SqlContext sqlContext = walker.buildAntlrTree(); ElasticDslContext elasticDslContext=new ElasticDslContext(sqlContext); for(QueryParser parser:buildSqlParserChain()){ parser.parse(elasticDslContext); } return elasticDslContext.getParseResult(); }  ElasticSqlParseResult parse(String sql);  }