A guide to the InfluxDBMapper and QueryBuilder for Java Part: Into and Order
Previously we used the group by statement extensively in order to execute complex aggregation queries
On this tutorial we are going to have a look at ‘into’ statements and the ‘order by’ close.
Apart from inserting or selecting data we might as well want to persist the results from one query into another table. The usages on something like this can vary. For example you might have a complex operation that cannot be executed in one single query.
Before we continue, make sure you have an influxdb instance up and running.
The most common action with an into query would be to populate a measurement with the results of a previous query.
Let’s copy a database.
The result of this query will be to copy the results into the h2o_feet_copy_1 measurement.
Now let’s just copy a column into another table.
Bellow is the query which is going to be execcuted.
Also we can do exactly the same thing with aggregations.
And generate a query which persists the aggregation result into a table.
Influxdb does provide ordering however it is limited only to dates.
So we will execute a query with ascending order.
And we get the ascending ordering as expected.
And the same query we shall executed with descending order.
That’s it! We just created some new databases and measurements by just using existing data in our database. We also executed some statements where we specified the time ordering.
You can find the sourcecode in github.
Published on Java Code Geeks with permission by Emmanouil Gkatziouras, partner at our JCG program. See the original article here: A guide to the InfluxDBMapper and QueryBuilder for Java Part: Into and Order
Opinions expressed by Java Code Geeks contributors are their own.