Merge pull request #667 from influxdata/flux/update-type-conversions

Update Flux type-conversion functions
pull/664/head
Scott Anderson 2019-12-10 16:36:16 -07:00 committed by GitHub
commit 21d2ec36d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 76 additions and 7 deletions

View File

@ -24,6 +24,8 @@ bool(v: "true")
### v ### v
The value to convert. The value to convert.
_**Data type:** Float | Integer | String | Uinteger_
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -24,6 +24,8 @@ bytes(v: "1m")
### v ### v
The value to convert. The value to convert.
_**Data type:** String_
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -24,6 +24,13 @@ duration(v: "1m")
### v ### v
The value to convert. The value to convert.
_**Data type:** Integer | String | Uinteger_
{{% note %}}
`duration()` assumes **numeric** input values are **nanoseconds**.
**String** input values must use [duration literal representation](#/v2.0/reference/flux/language/lexical-elements/#duration-literals).
{{% /note %}}
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -24,6 +24,8 @@ float(v: "3.14")
### v ### v
The value to convert. The value to convert.
_**Data type:** Boolean | Integer | Numeric String | Uinteger_
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -24,6 +24,15 @@ int(v: "4")
### v ### v
The value to convert. The value to convert.
_**Data type:** Boolean | Duration | Float | Numeric String | Time | Uinteger_
For duration and time values, `int()` returns the following:
| Input type | Returned value |
|:---------- |:-------------- |
| Duration | The number of nanoseconds in the specified duration |
| Time | A nanosecond epoch timestamp |
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -24,6 +24,8 @@ string(v: 123456789)
### v ### v
The value to convert. The value to convert.
_**Data type:** Boolean | Bytes | Duration | Float | Integer | Time | Uinteger_
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -24,6 +24,12 @@ time(v: "2016-06-13T17:43:50.1004002Z")
### v ### v
The value to convert. The value to convert.
_**Data type:** Integer | String | Uinteger_
{{% note %}}
`time()` assumes all numeric input values are nanosecond epoch timestamps.
{{% /note %}}
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")

View File

@ -14,12 +14,13 @@ weight: 501
The `toBool()` function converts all values in the `_value` column to booleans. The `toBool()` function converts all values in the `_value` column to booleans.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** Boolean_
```js ```js
toBool() toBool()
``` ```
_**Supported data types:** Float | Integer | String | Uinteger_
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -18,12 +18,18 @@ weight: 501
The `toDuration()` function converts all values in the `_value` column to durations. The `toDuration()` function converts all values in the `_value` column to durations.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** Duration_
```js ```js
toDuration() toDuration()
``` ```
_**Supported data types:** Integer | String | Uinteger_
{{% note %}}
`duration()` assumes **numeric** input values are **nanoseconds**.
**String** input values must use [duration literal representation](#/v2.0/reference/flux/language/lexical-elements/#duration-literals).
{{% /note %}}
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -14,12 +14,13 @@ weight: 501
The `toFloat()` function converts all values in the `_value` column to floats. The `toFloat()` function converts all values in the `_value` column to floats.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** Float_
```js ```js
toFloat() toFloat()
``` ```
_**Supported data types:** Boolean | Integer | Numeric String | Uinteger_
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -14,12 +14,20 @@ weight: 501
The `toInt()` function converts all values in the `_value` column to integers. The `toInt()` function converts all values in the `_value` column to integers.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** Integer_
```js ```js
toInt() toInt()
``` ```
_**Supported data types:** Boolean | Duration | Float | Numeric String | Time | Uinteger_
For duration and time values, `toInt()` returns the following:
| Input type | Returned value |
|:---------- |:-------------- |
| Duration | The number of nanoseconds in the specified duration |
| Time | A nanosecond epoch timestamp |
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -14,12 +14,13 @@ weight: 501
The `toString()` function converts all values in the `_value` column to strings. The `toString()` function converts all values in the `_value` column to strings.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** String_
```js ```js
toString() toString()
``` ```
_**Supported data types:** Boolean | Bytes | Duration | Float | Integer | Time | Uinteger_
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -14,12 +14,17 @@ weight: 501
The `toTime()` function converts all values in the `_value` column to times. The `toTime()` function converts all values in the `_value` column to times.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** Time_
```js ```js
toTime() toTime()
``` ```
_**Supported data types:** Integer | String | Uinteger_
{{% note %}}
`toTime()` assumes all numeric input values are nanosecond epoch timestamps.
{{% /note %}}
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -14,12 +14,20 @@ weight: 501
The `toUInt()` function converts all values in the `_value` column to UIntegers. The `toUInt()` function converts all values in the `_value` column to UIntegers.
_**Function type:** Type conversion_ _**Function type:** Type conversion_
_**Output data type:** UInteger_
```js ```js
toUInt() toUInt()
``` ```
_**Supported data types:** Boolean | Duration | Float | Integer | Numeric String | Time_
For duration and time values, `toUint()` returns the following:
| Input type | Returned value |
|:---------- |:-------------- |
| Duration | The number of nanoseconds in the specified duration |
| Time | A nanosecond epoch timestamp |
{{% note %}} {{% note %}}
To convert values in a column other than `_value`, define a custom function To convert values in a column other than `_value`, define a custom function
patterned after the [function definition](#function-definition), patterned after the [function definition](#function-definition),

View File

@ -24,6 +24,15 @@ uint(v: "4")
### v ### v
The value to convert. The value to convert.
_**Data type:** Boolean | Duration | Float | Integer | Numeric String | Time_
For duration and time values, `uint()` returns the following:
| Input type | Returned value |
|:---------- |:-------------- |
| Duration | The number of nanoseconds in the specified duration |
| Time | A nanosecond epoch timestamp |
## Examples ## Examples
```js ```js
from(bucket: "sensor-data") from(bucket: "sensor-data")