influxdata / influxdb-java

Java client for InfluxDB
MIT License
1.19k stars 478 forks source link

SelectionQueryImpl should support buildQueryString #960

Open kondubhSICKAG opened 1 year ago

kondubhSICKAG commented 1 year ago

If I want to create a query using dynamic selections, for example say from UI we received a request for aggregate function List functions; which as max,min for columns "test1". This list of functions can be dynamic. Now I cannot use query build to build a query dynamically. SelectionQueryImpl can be used but this cannot generate a string, Is there a work around? or is there a way that i can build select query dynamically when using aggregate functions?

SelectionQueryImpl selection= select(); selection.column(searchFilter.getName().get(0)).function(searchFilter.getFunctions().get(0).toString()); selection.function("mean", searchFilter.getName().get(0)); selection.function("min", searchFilter.getName().get(0)); selection.from(bucket,(ObjectUtils.isNotEmpty(searchFilter.getType()))? searchFilter.getType().stream().toArray(String[]::new): new String[0]);