iamazy / elasticsearch-sql

parse sql into elasticsearch dsl with antlr4
https://iamazy.github.io/elasticsearch-sql/
MIT License
339 stars 89 forks source link

sql Customise function #103

Open robocon20x opened 1 year ago

robocon20x commented 1 year ago

Hi guys, i want to translate this SQL to DSL, how can I convert it ?: SQL: Select case when name = 'A' then 'NO' else 'YES' end as test from index_table

in java app, I code like this : String sql = "Select case when name = 'A' then 'NO' else 'YES' end as test from index_table"; // sql = sql.replace("\"",""); ElasticSql2DslParser a = new ElasticSql2DslParser(); ElasticSqlParseResult b = a.parse(sql); // System.out.println(JsonUtil.toJson(b,ElasticSqlParseResult.clasSELECT name.exact as test from v3_customers_33167s)); SearchRequest c = b.getSearchRequest(); // b.toPrettyDsl(c); // System.out.println(JsonUtil.toJson(c,SearchRequest.class)); System.out.println(b.toPrettyDsl(c));

    Thanks and best regards
iamazy commented 1 year ago

Hi, @robocon20x, this sql is still unsupported