Flux 0.109 (#2354)
* added flux 0.109.0 and 0.109.1 release notes * Document changes to Flux string interpolation (#2326) * Add new content on string interpolation from SPEC.md Closes #2314 * added the stringable constraint * Update content/influxdb/v2.0/reference/flux/language/string-interpolation.md Co-authored-by: pierwill <pierwill@users.noreply.github.com> Co-authored-by: Scott Anderson <scott@influxdata.com> Co-authored-by: Scott Anderson <sanderson@users.noreply.github.com> * Add 'mode' parameter to 'csv.from' (#2353) * updated csv.from with new mode parameter * minor updates to csv.from * updated description of raw csv parsing mode * updated csv.from in cloud, updated raw parse mode description Co-authored-by: pierwill <19642016+pierwill@users.noreply.github.com> Co-authored-by: pierwill <pierwill@users.noreply.github.com>pull/2356/head
parent
0b796c5fed
commit
871c0db598
|
@ -12,72 +12,4 @@ menu:
|
||||||
weight: 202
|
weight: 202
|
||||||
---
|
---
|
||||||
|
|
||||||
The `csv.from()` function retrieves data from a comma-separated value (CSV) data source.
|
{{< duplicate-oss >}}
|
||||||
It returns a stream of tables.
|
|
||||||
Each unique series is contained within its own table.
|
|
||||||
Each record in the table represents a single point in the series.
|
|
||||||
|
|
||||||
_**Function type:** Input_
|
|
||||||
|
|
||||||
```js
|
|
||||||
import "csv"
|
|
||||||
|
|
||||||
csv.from(csv: csvData)
|
|
||||||
|
|
||||||
// OR
|
|
||||||
|
|
||||||
csv.from(file: "/path/to/data-file.csv")
|
|
||||||
```
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
### csv
|
|
||||||
Annotated CSV text.
|
|
||||||
|
|
||||||
{{% note %}}
|
|
||||||
CSV data must use Annotated CSV syntax and include all
|
|
||||||
[annotation rows](/influxdb/cloud/reference/syntax/annotated-csv/#annotations).
|
|
||||||
For more information, see [Annotated CSV](/influxdb/cloud/reference/syntax/annotated-csv/).
|
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
_**Data type:** String_
|
|
||||||
|
|
||||||
### file
|
|
||||||
The file path of the CSV file to query.
|
|
||||||
The path can be absolute or relative.
|
|
||||||
If relative, it is relative to the working directory of the `fluxd` process.
|
|
||||||
_The CSV file must exist in the same file system running the `fluxd` process._
|
|
||||||
|
|
||||||
{{% warn %}}
|
|
||||||
**InfluxDB OSS** and **{{< cloud-name "short" >}}** user interfaces do _**not**_ support the `file` parameter.
|
|
||||||
Neither allow access to the underlying filesystem.
|
|
||||||
However, the [Flux REPL](/influxdb/cloud/tools/repl/) does support the `file` parameter.
|
|
||||||
{{% /warn %}}
|
|
||||||
|
|
||||||
_**Data type:** String_
|
|
||||||
|
|
||||||
## Examples
|
|
||||||
|
|
||||||
### Query CSV data from a file
|
|
||||||
```js
|
|
||||||
import "csv"
|
|
||||||
|
|
||||||
csv.from(file: "/path/to/data-file.csv")
|
|
||||||
```
|
|
||||||
|
|
||||||
### Query raw CSV-formatted text
|
|
||||||
```js
|
|
||||||
import "csv"
|
|
||||||
|
|
||||||
csvData = "
|
|
||||||
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,string,string,double
|
|
||||||
#group,false,false,false,false,false,false,false,false
|
|
||||||
#default,,,,,,,,
|
|
||||||
,result,table,_start,_stop,_time,region,host,_value
|
|
||||||
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
|
|
||||||
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
|
|
||||||
,mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
|
|
||||||
"
|
|
||||||
|
|
||||||
csv.from(csv: csvData)
|
|
||||||
```
|
|
||||||
|
|
|
@ -27,19 +27,19 @@ name = "John"
|
||||||
// My name is John.
|
// My name is John.
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% note %}}
|
String interpolation expressions must satisfy the
|
||||||
#### Flux only interpolates string values
|
[Stringable constraint](/influxdb/v2.0/reference/flux/language/types/#stringable-constraint).
|
||||||
Flux currently interpolates only string values ([IMP#1775](https://github.com/influxdata/flux/issues/1775)).
|
|
||||||
Use the [string() function](/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/type-conversions/string/)
|
|
||||||
to convert non-string values to strings.
|
|
||||||
|
|
||||||
|
##### Arbitrary expression interpolation example:
|
||||||
```js
|
```js
|
||||||
count = 12
|
n = duration(v: "1m")
|
||||||
|
"the answer is ${n}"
|
||||||
|
// the answer is 1m
|
||||||
|
|
||||||
"I currently have ${string(v: count)} cats."
|
t0 = time(v: "2016-06-13T17:43:50.1004002Z")
|
||||||
|
"the answer is ${t0}"
|
||||||
|
// the answer is 2016-06-13T17:43:50.1004002Z
|
||||||
```
|
```
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
|
|
||||||
## Use dot notation to interpolate record values
|
## Use dot notation to interpolate record values
|
||||||
[Records](/influxdb/v2.0/reference/flux/language/expressions/#record-literals) consist of key-value pairs.
|
[Records](/influxdb/v2.0/reference/flux/language/expressions/#record-literals) consist of key-value pairs.
|
||||||
|
|
|
@ -273,8 +273,12 @@ Boolean, Integer, Uinteger, Float, String, Duration, and Time types are `Nullabl
|
||||||
Records are the only types that fall under this constraint.
|
Records are the only types that fall under this constraint.
|
||||||
|
|
||||||
### Negatable Constraint
|
### Negatable Constraint
|
||||||
Negatable types ore those the unary arithmetic operator `-` accepts.
|
Negatable types are those the unary arithmetic operator `-` accepts.
|
||||||
Integer, Uinteger, Float, and Duration types are `Negatable`.
|
Integer, Uinteger, Float, and Duration types are `Negatable`.
|
||||||
|
|
||||||
### Timeable Constraint
|
### Timeable Constraint
|
||||||
Duration and Time types are `Timeable`.
|
Duration and Time types are `Timeable`.
|
||||||
|
|
||||||
|
##### Stringable Constraint
|
||||||
|
Stringable types are those that can be evaluated and expressed in string interpolation.
|
||||||
|
String, Integer, Uinteger, Float, Boolean, Time, and Duration types are `Stringable`.
|
||||||
|
|
|
@ -22,22 +22,28 @@ _**Function type:** Input_
|
||||||
```js
|
```js
|
||||||
import "csv"
|
import "csv"
|
||||||
|
|
||||||
csv.from(csv: csvData)
|
csv.from(
|
||||||
|
csv: csvData,
|
||||||
|
mode: "annotations"
|
||||||
|
)
|
||||||
|
|
||||||
// OR
|
// OR
|
||||||
|
|
||||||
csv.from(file: "/path/to/data-file.csv")
|
csv.from(
|
||||||
|
file: "/path/to/data-file.csv",
|
||||||
|
mode: "annotations"
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
|
||||||
### csv
|
### csv
|
||||||
Annotated CSV text.
|
CSV data.
|
||||||
|
Supports [annotated CSV](/influxdb/v2.0/reference/syntax/annotated-csv/) or raw CSV.
|
||||||
|
Use [`mode`](#mode) to specify the parsing mode.
|
||||||
|
|
||||||
{{% note %}}
|
{{% note %}}
|
||||||
CSV data must use Annotated CSV syntax and include all
|
Annotated CSV data must include all [annotation rows](/influxdb/v2.0/reference/syntax/annotated-csv/#annotations).
|
||||||
[annotation rows](/influxdb/v2.0/reference/syntax/annotated-csv/#annotations).
|
|
||||||
For more information, see [Annotated CSV](/influxdb/v2.0/reference/syntax/annotated-csv/).
|
|
||||||
{{% /note %}}
|
{{% /note %}}
|
||||||
|
|
||||||
_**Data type:** String_
|
_**Data type:** String_
|
||||||
|
@ -56,16 +62,43 @@ However, the [Flux REPL](/influxdb/v2.0/tools/repl/) does support the `file` par
|
||||||
|
|
||||||
_**Data type:** String_
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### mode
|
||||||
|
CSV parsing mode.
|
||||||
|
Default is `annotations`.
|
||||||
|
|
||||||
|
_**Data type:** String_
|
||||||
|
|
||||||
|
##### Available modes
|
||||||
|
- **annotations:** Use CSV annotations to determine column data types.
|
||||||
|
- **raw:** Parse all columns as strings and use the first row as the
|
||||||
|
[header row](/influxdb/v2.0/reference/syntax/annotated-csv/#rows) and all
|
||||||
|
subsequent rows as data.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Query CSV data from a file
|
- [Query annotated CSV data from a file](#query-annotated-csv-data-from-a-file)
|
||||||
|
- [Query raw CSV data from a file](#query-raw-csv-data-from-a-file)
|
||||||
|
- [Query an annotated CSV string](#query-an-annotated-csv-string)
|
||||||
|
- [Query a raw CSV string](#query-a-raw-csv-string)
|
||||||
|
|
||||||
|
##### Query annotated CSV data from a file
|
||||||
```js
|
```js
|
||||||
import "csv"
|
import "csv"
|
||||||
|
|
||||||
csv.from(file: "/path/to/data-file.csv")
|
csv.from(file: "/path/to/data-file.csv")
|
||||||
```
|
```
|
||||||
|
|
||||||
### Query raw CSV-formatted text
|
##### Query raw CSV data from a file
|
||||||
|
```js
|
||||||
|
import "csv"
|
||||||
|
|
||||||
|
csv.from(
|
||||||
|
file: "/path/to/data-file.csv",
|
||||||
|
mode: "raw"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Query an annotated CSV string
|
||||||
```js
|
```js
|
||||||
import "csv"
|
import "csv"
|
||||||
|
|
||||||
|
@ -81,3 +114,20 @@ csvData = "
|
||||||
|
|
||||||
csv.from(csv: csvData)
|
csv.from(csv: csvData)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Query a raw CSV string
|
||||||
|
```js
|
||||||
|
import "csv"
|
||||||
|
|
||||||
|
csvData = "
|
||||||
|
_start,_stop,_time,region,host,_value
|
||||||
|
2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
|
||||||
|
2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
|
||||||
|
2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
|
||||||
|
"
|
||||||
|
|
||||||
|
csv.from(
|
||||||
|
csv: csvData,
|
||||||
|
mode: "raw"
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
|
@ -8,6 +8,28 @@ menu:
|
||||||
name: Flux
|
name: Flux
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## v0.109.1 [2021-03-24]
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- Perform testing checks as part of query `done`.
|
||||||
|
- Delimited multi-result encoder properly releases results before checking for errors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## v0.109.0 [2021-03-23]
|
||||||
|
|
||||||
|
### Features
|
||||||
|
- Add support for null values in string interpolation.
|
||||||
|
- Add support for all basic datatypes in string interpolation.
|
||||||
|
- Add support for parsing CSV files without annotations.
|
||||||
|
- Support formatting the AST from `libflux`.
|
||||||
|
|
||||||
|
### Bug fixes
|
||||||
|
- Add error handling for wrong number of fields for raw CSV.
|
||||||
|
- Change Rust version to be updated manually.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## v0.108.1 [2021-03-15]
|
## v0.108.1 [2021-03-15]
|
||||||
- _Internal code cleanup._
|
- _Internal code cleanup._
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue