Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of SELECT <certain columns> in Flux Query Language?

What would be equivalent flux query for SELECT address, name FROM addresses ? (I am referring to FluxQL, the new query language developed by InfluxData)

I didn't find a clear answer to this in the limited Flux Documentation present. Flux documentation says that filter() function is the equivalent of both SELECT and WHERE clauses, but all examples given are equivalent of WHERE clauses, nothing on SELECT.

These are the documentation for FluxQL for better reference:

https://docs.influxdata.com/flux/v0.50/introduction/getting-started

https://v2.docs.influxdata.com/v2.0/query-data/get-started/

like image 369
Sushovan Mandal Avatar asked Mar 09 '20 11:03

Sushovan Mandal


People also ask

What is flux query?

Flux is a standalone data scripting and query language that increases productivity and code reuse. Flux is optimized for ETL, monitoring, and alerting, with an inline planner and optimizer. Flux is the result of the open source community driving innovation with time series data.

What is fields and tags in InfluxDB?

InfluxDB lets you specify fields and tags, both being key/value pairs where the difference is that tags are automatically indexed. Because fields are not being indexed at all, on every query where InfluxDB is asked to find a specified field, it needs to sequentially scan every value of the field column.

What is flux DB?

Flux is InfluxData's functional data scripting language designed for querying, analyzing, and acting on data.


1 Answers

maybe you need something like this:

filter(fn: (r) => r._measurement == "addresses" and (r._field == "address" or r._field == "name"))
|> pivot(rowKey:["_time"], columnKey:["_field"], valueColumn:"_value")
|> drop(columns:["_value", ...])

in the "drop" (instead of ...) you can list all excesses columns

like image 123
Abel Nightroad Avatar answered Nov 15 '22 15:11

Abel Nightroad