Hi,
I’m not able to get the findColumn() function to work even when following the example from the documentation at Extract scalar values in Flux | InfluxDB OSS 2.7 Documentation (Extract a column).
All I get is the following error:
Error: failed to execute query: 400 Bad Request: error in query specification while starting program: this Flux script returns no streaming data. Consider adding a “yield” or invoking streaming functions directly, without performing an assignment
Ive tried to add a yield before findColumn(), and it seems to just return the sample data as is and never gets to findColumn(), ie I no longer get the error, but a the same data is returned whether i include findColumn() in the script or not.
Environment
$ influxd version
InfluxDB 2.6.1 (git: 9dcf880fe0) build_date: 2022-12-29T13:14:07Z
$ influx version
Influx CLI 2.7.3 (git: 8b962c7e75) build_date: 2023-04-28T14:22:49Z
Basically I’m running the query below from the either a macos or linux command line and getting the error. Also getting the error when running the query via the python influxdb_client.
Any ideas as to what I am doing wrong?
Thanks!
influx query ’
import “array”
sampleData =
array.from(
rows: [
{_time: 2019-11-01T12:00:00Z, location: “sfo”, _field: “temp”, _value: 65.1},
{_time: 2019-11-01T13:00:00Z, location: “sfo”, _field: “temp”, _value: 66.2},
{_time: 2019-11-01T14:00:00Z, location: “sfo”, _field: “temp”, _value: 66.3},
{_time: 2019-11-01T15:00:00Z, location: “sfo”, _field: “temp”, _value: 66.8},
{_time: 2019-11-01T12:00:00Z, location: “kjfk”, _field: “temp”, _value: 69.4},
{_time: 2019-11-01T13:00:00Z, location: “kjfk”, _field: “temp”, _value: 69.9},
{_time: 2019-11-01T14:00:00Z, location: “kjfk”, _field: “temp”, _value: 71.0},
{_time: 2019-11-01T15:00:00Z, location: “kjfk”, _field: “temp”, _value: 71.2},
{_time: 2019-11-01T12:00:00Z, location: “kord”, _field: “temp”, _value: 46.4},
{_time: 2019-11-01T13:00:00Z, location: “kord”, _field: “temp”, _value: 46.3},
{_time: 2019-11-01T14:00:00Z, location: “kord”, _field: “temp”, _value: 42.7},
{_time: 2019-11-01T15:00:00Z, location: “kord”, _field: “temp”, _value: 38.9},
],
)
|> group(columns: [“location”, “_field”])
sampleData
|> findColumn(
fn: (key) => key._field == “temp” and key.location == “sfo”,
column: “_value”,
)
// Returns [65.1, 66.2, 66.3, 66.8]
’