array.from() function

The array.from() function is experimental and subject to change at any time. By using this function, you accept the risks of experimental functions.

The experimental array.from() function constructs a table from an array of records. Each record in the array is converted into an output row or record. All records must have the same keys and data types.

*Function type: Input*

  1. import "experimental/array"
  2. array.from(rows: [
  3. {_time: 2020-01-01T00:00:00Z, _field: "exampleField", _value: 3, foo: "bar"},
  4. {_time: 2020-01-01T00:01:00Z, _field: "exampleField", _value: 4, foo: "bar"},
  5. {_time: 2020-01-01T00:02:00Z, _field: "exampleField", _value: 1, foo: "bar"}
  6. ])

Parameters

rows

Array of records to construct a table with.

*Data type: Array of records*

Examples

Build an arbitrary table
  1. import "experimental/array"
  2. rows = [
  3. {foo: "bar", baz: 21.2}
  4. {foo: "bar", baz: 23.8}
  5. ]
  6. array.from(rows: rows)
Union custom rows with query results
  1. import "influxdata/influxdb/v1"
  2. import "experimental/array"
  3. tags = v1.tagValues(
  4. bucket: "example-bucket",
  5. tag: "host"
  6. )
  7. wildcard_tag = array.from(rows: [{_value: "*"}])
  8. union(tables: [tags, wildcard_tag])