Merge pull request #448 from influxdata/flux-0.43

Flux 0.43
pull/427/head
Scott Anderson 2019-09-09 16:37:35 -06:00 committed by GitHub
commit 7c980c63fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 108 additions and 4 deletions

View File

@ -86,7 +86,7 @@ $article-note-table-row-alt: #3B2862;
$article-note-table-scrollbar: $np-deepnight; $article-note-table-scrollbar: $np-deepnight;
$article-note-shadow: $np-deepnight; $article-note-shadow: $np-deepnight;
$article-note-code: $cp-comet; $article-note-code: $cp-comet;
$article-note-code-bg: $wp-telopea; $article-note-code-bg: $wp-jaguar;
$article-note-code-accent1: #567375; $article-note-code-accent1: #567375;
$article-note-code-accent2: $b-pool; $article-note-code-accent2: $b-pool;
$article-note-code-accent3: $gr-viridian; $article-note-code-accent3: $gr-viridian;

View File

@ -24,6 +24,7 @@ $g19-ghost: #FAFAFC;
$g20-white: #FFFFFF; // Brand color $g20-white: #FFFFFF; // Brand color
// Warm Purples - Magentas // Warm Purples - Magentas
$wp-jaguar: #1d0135;
$wp-telopea: #23043E; $wp-telopea: #23043E;
$wp-violentdark: #2d0749; $wp-violentdark: #2d0749;
$wp-violet: #32094E; $wp-violet: #32094E;

View File

@ -294,9 +294,9 @@ StringExpression = "${" Expression "}" .
``` ```
String literals are also interpolated for embedded expressions to be evaluated as strings. String literals are also interpolated for embedded expressions to be evaluated as strings.
Embedded expressions are enclosed within the literals `${` and `}` respectively. Embedded expressions are enclosed in a dollar sign and curly braces (`${}`).
The expressions are evaluated in the scope containing the string literal. The expressions are evaluated in the scope containing the string literal.
The result of an expression is formatted as a string and replaces the string content between the brackets. The result of an expression is formatted as a string and replaces the string content between the braces.
All types are formatted as strings according to their literal representation. All types are formatted as strings according to their literal representation.
A function `printf` exists to allow more precise control over formatting of various types. A function `printf` exists to allow more precise control over formatting of various types.
To include the literal `${` within a string, it must be escaped. To include the literal `${` within a string, it must be escaped.

View File

@ -0,0 +1,96 @@
---
title: String interpolation
description: >
Flux string interpolation evaluates string literals containing one or more placeholders
and returns a result with placeholders replaced with their corresponding values.
menu:
v2_0_ref:
parent: Flux specification
name: String interpolation
weight: 211
---
Flux string interpolation evaluates string literals containing one or more placeholders
and returns a result with placeholders replaced with their corresponding values.
## String interpolation syntax
To use Flux string interpolation, enclose embedded [expressions](/v2.0/reference/flux/language/expressions/)
in a dollar sign and curly braces `${}`.
Flux replaces the content between the braces with the result of the expression and
returns a string literal.
```js
name = "John"
"My name is ${name}."
// My name is John.
```
{{% note %}}
#### Flux only interpolates string values
Flux currently interpolates only string values ([IMP#1775](https://github.com/influxdata/flux/issues/1775)).
Use the [string() function](/v2.0/reference/flux/functions/built-in/transformations/type-conversions/string/)
to convert non-string values to strings.
```js
count = 12
"I currently have ${string(v: count)} cats."
```
{{% /note %}}
## Use dot notation to interpolate object values
[Objects](/v2.0/reference/flux/language/expressions/#object-literals) consist of key-value pairs.
Use [dot notation](/v2.0/reference/flux/language/expressions/#member-expressions)
to interpolate values from an object.
```js
person = {
name: "John",
age: 42
}
"My name is ${person.name} and I'm ${string(v: person.age)} years old."
// My name is John and I'm 42 years old.
```
Flux returns each record in query results as an object.
In Flux row functions, each row object is represented by `r`.
Use dot notation to interpolate specific column values from the `r` object.
##### Use string interpolation to add a human-readable message
```js
from(bucket: "example-bucket")
|> range(start: -30m)
|> map(fn: (r) => ({
r with
human-readable: "${r._field} is ${r._value} at ${string(v: r._time)}."
}))
```
## String interpolation versus concatenation
Flux supports both string interpolation and string concatenation.
String interpolation is a more concise method for achieving the same result.
```js
person = {
name: "John",
age: 42
}
// String interpolation
"My name is ${person.name} and I'm ${string(v: person.age)} years old."
// String concatenation
"My name is " + person.name + " and I'm " + string(v: person.age) + " years old."
// Both return: My name is John and I'm 42 years old.
```
{{% note %}}
Check and notification message templates configured in the InfluxDB user interface
**do not** support string concatenation.
{{% /note %}}

View File

@ -11,13 +11,20 @@ aliases:
--- ---
{{% note %}} {{% note %}}
_The latest release of InfluxDB v2.0 alpha includes **Flux v0.42.0**. _The latest release of InfluxDB v2.0 alpha includes **Flux v0.43.0**.
Though newer versions of Flux may be available, they will not be included with Though newer versions of Flux may be available, they will not be included with
InfluxDB until the next InfluxDB v2.0 release._ InfluxDB until the next InfluxDB v2.0 release._
{{% /note %}} {{% /note %}}
--- ---
## v0.43.0 [2019-09-04]
### Features
- PagerDuty endpoint for alerts and notifications.
---
## v0.42.0 [2019-08-30] ## v0.42.0 [2019-08-30]
### Features ### Features