From 60631034220c0a9225122192fc748a091d16a8bf Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Tue, 12 Feb 2019 16:35:41 -0700 Subject: [PATCH 1/4] updated flux built-in functions, added contains function --- .../flux/functions/built-in/inputs/_index.md | 6 +-- .../flux/functions/built-in/misc/_index.md | 8 ++-- .../flux/functions/built-in/outputs/_index.md | 6 +-- .../flux/functions/built-in/tests/_index.md | 15 ++++++ .../flux/functions/built-in/tests/contains.md | 46 +++++++++++++++++++ .../built-in/transformations/_index.md | 6 +-- .../transformations/aggregates/_index.md | 6 +-- .../transformations/selectors/_index.md | 6 +-- .../type-conversions/_index.md | 6 +-- 9 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 content/v2.0/reference/flux/functions/built-in/tests/_index.md create mode 100644 content/v2.0/reference/flux/functions/built-in/tests/contains.md diff --git a/content/v2.0/reference/flux/functions/built-in/inputs/_index.md b/content/v2.0/reference/flux/functions/built-in/inputs/_index.md index 681e49dc7..8fde865cd 100644 --- a/content/v2.0/reference/flux/functions/built-in/inputs/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/inputs/_index.md @@ -1,6 +1,6 @@ --- -title: Flux input functions -description: Flux input functions define sources of data or or display information about data sources. +title: Flux built-in input functions +description: Flux's built-in input functions define sources of data or or display information about data sources. aliases: - /v2.0/reference/flux/functions/inputs menu: @@ -11,7 +11,7 @@ menu: weight: 301 --- -Flux input functions define sources of data or display information about data sources. +Flux's built-in input functions define sources of data or display information about data sources. The following input functions are available: {{< children type="functions" >}} diff --git a/content/v2.0/reference/flux/functions/built-in/misc/_index.md b/content/v2.0/reference/flux/functions/built-in/misc/_index.md index 47da3c2e9..e9eb9a6cb 100644 --- a/content/v2.0/reference/flux/functions/built-in/misc/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/misc/_index.md @@ -1,6 +1,8 @@ --- -title: Flux miscellaneous functions -description: Flux provides miscellaneous functions that serve purposes other than retrieving, transforming, or outputting data. +title: Flux built-in miscellaneous functions +description: > + Flux provides built-in miscellaneous functions that serve purposes other than + retrieving, transforming, or outputting data. aliases: - /v2.0/reference/flux/functions/misc menu: @@ -11,7 +13,7 @@ menu: weight: 305 --- -Flux functions primarily retrieve, shape and transform, then output data, however +Flux's built-in functions primarily retrieve, shape and transform, then output data, however there are functions available that serve other purposes. The following functions are are available but don't fit within other function categories: diff --git a/content/v2.0/reference/flux/functions/built-in/outputs/_index.md b/content/v2.0/reference/flux/functions/built-in/outputs/_index.md index c6307dd10..3f614040f 100644 --- a/content/v2.0/reference/flux/functions/built-in/outputs/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/outputs/_index.md @@ -1,6 +1,6 @@ --- -title: Flux output functions -description: Flux output functions yield results or send data to a specified output destination. +title: Flux built-in output functions +description: Flux's built-in output functions yield results or send data to a specified output destination. aliases: - /v2.0/reference/flux/functions/outputs menu: @@ -11,7 +11,7 @@ menu: weight: 302 --- -Flux output functions yield results or send data to a specified output destination. +Flux's built-in output functions yield results or send data to a specified output destination. The following output functions are are available: {{< children type="functions" >}} diff --git a/content/v2.0/reference/flux/functions/built-in/tests/_index.md b/content/v2.0/reference/flux/functions/built-in/tests/_index.md new file mode 100644 index 000000000..58421666e --- /dev/null +++ b/content/v2.0/reference/flux/functions/built-in/tests/_index.md @@ -0,0 +1,15 @@ +--- +title: Flux built-in testing functions +description: Flux's built-in testing functions test various aspects of piped-forward data. +menu: + v2_0_ref: + name: Tests + identifier: built-in-tests + parent: Built-in +weight: 305 +--- + +Flux's built-in testing functions test various aspects of piped-forward data. +The following built-in testing functions are available: + +{{< children type="functions" show="pages" >}} diff --git a/content/v2.0/reference/flux/functions/built-in/tests/contains.md b/content/v2.0/reference/flux/functions/built-in/tests/contains.md new file mode 100644 index 000000000..75e670986 --- /dev/null +++ b/content/v2.0/reference/flux/functions/built-in/tests/contains.md @@ -0,0 +1,46 @@ +--- +title: contains() function +description: The contains() function tests whether a value is a member of a set. +menu: + v2_0_ref: + name: contains + parent: built-in-tests +weight: 401 +--- + +The `contains()` function tests whether a value is a member of a set. +If the value is a member of the set, the function returns `true`. +If the value is not a member of the set, the functions returns `false`. + +```js +contains( + value: 1, + set: [1,2,3] +) +``` + +## Parameters + +### value +The value for which to search. + +_**Data type:** Boolean | Integer | UInteger | Float | String | Time_ + +### set +The set of values in which to search. + +_**Data type:** Array of Booleans | Integers | UIntegers | Floats | Strings | Times_ + +## Examples + +###### Filter on a set of specific fields +```js +fields = ["load1", "load5", "load15"] + +from(bucket) + |> range(start:start, stop: stop) + |> filter(fn: (r) => + r._measurement == "system" and + contains(value: r._field, set: fields) + ) +``` diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/_index.md b/content/v2.0/reference/flux/functions/built-in/transformations/_index.md index 276935dec..d86a4b2df 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/_index.md @@ -1,6 +1,6 @@ --- -title: Flux transformation functions -description: Flux transformation functions transform and shape your data in specific ways. +title: Flux built-in transformation functions +description: Flux's built-in transformation functions transform and shape your data in specific ways. aliases: - /v2.0/reference/flux/functions/transformations menu: @@ -11,7 +11,7 @@ menu: weight: 303 --- -Flux transformation functions transform or shape your data in specific ways. +Flux's built-in transformation functions transform or shape your data in specific ways. There are different types of transformations categorized below: {{< children show="sections" >}} diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/_index.md b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/_index.md index 7294cf08f..27b86a41e 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/aggregates/_index.md @@ -1,6 +1,6 @@ --- -title: Flux aggregate functions -description: Flux aggregate functions take values from an input table and aggregate them in some way. +title: Flux built-in aggregate functions +description: Flux's built-in aggregate functions take values from an input table and aggregate them in some way. aliases: - /v2.0/reference/flux/functions/transformations/aggregates menu: @@ -11,7 +11,7 @@ menu: weight: 401 --- -Flux aggregate functions take values from an input table and aggregate them in some way. +Flux's built-in aggregate functions take values from an input table and aggregate them in some way. The output table contains is a single row with the aggregated value. Aggregate operations output a table for every input table they receive. diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/selectors/_index.md b/content/v2.0/reference/flux/functions/built-in/transformations/selectors/_index.md index 1f0388288..bad44eca6 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/selectors/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/selectors/_index.md @@ -1,6 +1,6 @@ --- -title: Flux selector functions -description: Flux selector functions return one or more records based on function logic. +title: Flux built-in selector functions +description: Flux's built-in selector functions return one or more records based on function logic. aliases: - /v2.0/reference/flux/functions/transformations/selectors menu: @@ -11,7 +11,7 @@ menu: weight: 401 --- -Flux selector functions return one or more records based on function logic. +Flux's built-in selector functions return one or more records based on function logic. The output table is different than the input table, but individual row values are not. The following selector functions are available: diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/type-conversions/_index.md b/content/v2.0/reference/flux/functions/built-in/transformations/type-conversions/_index.md index 1e4dc0bd9..c2898c24c 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/type-conversions/_index.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/type-conversions/_index.md @@ -1,6 +1,6 @@ --- -title: Flux type conversion functions -description: Flux type conversion functions convert columns of the input table into a specific data type. +title: Flux built-in type conversion functions +description: Flux's built-in built-in type conversion functions convert columns of the input table into a specific data type. aliases: - /v2.0/reference/flux/functions/transformations/type-conversions menu: @@ -11,7 +11,7 @@ menu: weight: 401 --- -Flux type conversion functions convert columns of the input table into a specific data type. +Flux's built-in type conversion functions convert columns of the input table into a specific data type. The following type conversion functions are available: {{< children type="functions" >}} From 0d9196c3910235c681fa98b7d3b646220161e818 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 13 Feb 2019 09:20:44 -0700 Subject: [PATCH 2/4] flux updates from spec --- .../built-in/transformations/statecount.md | 2 +- .../flux/language/assignment-scope.md | 3 +- .../reference/flux/language/expressions.md | 29 +++++++++++++++---- .../flux/language/lexical-elements.md | 4 +-- .../v2.0/reference/flux/language/packages.md | 3 +- .../reference/flux/language/statements.md | 2 +- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/statecount.md b/content/v2.0/reference/flux/functions/built-in/transformations/statecount.md index 98a3ee947..c70100cef 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/statecount.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/statecount.md @@ -12,7 +12,7 @@ weight: 401 The `stateCount()` function computes the number of consecutive records in a given state. The state is defined via the function `fn`. -For each consecutive point that evaluates as `true`, the state count will be incremented. +For each consecutive point that evaluates as `true`, the state count is incremented. When a point evaluates as `false`, the state count is reset. The state count is added as an additional column to each record. diff --git a/content/v2.0/reference/flux/language/assignment-scope.md b/content/v2.0/reference/flux/language/assignment-scope.md index 3957835c9..b12863302 100644 --- a/content/v2.0/reference/flux/language/assignment-scope.md +++ b/content/v2.0/reference/flux/language/assignment-scope.md @@ -66,7 +66,8 @@ OptionAssignment = "option" [ identifier "." ] identifier "=" Expression An option assignment creates an option bound to an identifier and gives it a type and a value. Options may only be assigned in a package block. -An identifier assigned to an option may be reassigned a new value but not a new type. +Once declared, an option may not be redeclared in the same package block. +An option declared in one package may be reassigned a new value in another. An option keeps the same type for the remainder of its lifetime. ###### Examples diff --git a/content/v2.0/reference/flux/language/expressions.md b/content/v2.0/reference/flux/language/expressions.md index caf2ca310..8c203f728 100644 --- a/content/v2.0/reference/flux/language/expressions.md +++ b/content/v2.0/reference/flux/language/expressions.md @@ -154,7 +154,24 @@ MemberBracketExpression = "[" string_lit "]" . ### Operators Operators combine operands into expressions. -Operator precedence is encoded directly into the grammar. +The precedence of the operators is given in the table below. +Operators with a lower number have higher precedence. + +|Precedence| Operator | Description | +|----------|----------|---------------------------| +| 1 | `a()` | Function call | +| | `a[]` | Member or index access | +| | `.` | Member access | +| 2 | `*` `/` |Multiplication and division| +| 3 | `+` `-` | Addition and subtraction | +| 4 |`==` `!=` | Comparison operators | +| | `<` `<=` | | +| | `>` `>=` | | +| |`=~` `!~` | | +| 5 | `not` | Unary logical expression | +| 6 |`and` `or`| Logical AND and OR | + +The operator precedence is encoded directly into the grammar as the following. ```js Expression = LogicalExpression . @@ -167,12 +184,12 @@ UnaryLogicalOperator = "not" . ComparisonExpression = MultiplicativeExpression | ComparisonExpression ComparisonOperator MultiplicativeExpression . ComparisonOperator = "==" | "!=" | "<" | "<=" | ">" | ">=" | "=~" | "!~" . -MultiplicativeExpression = AdditiveExpression - | MultiplicativeExpression MultiplicativeOperator AdditiveExpression . -MultiplicativeOperator = "*" | "/" . -AdditiveExpression = PipeExpression - | AdditiveExpression AdditiveOperator PipeExpression . +AdditiveExpression = MultiplicativeExpression + | AdditiveExpression AdditiveOperator MultiplicativeExpression . AdditiveOperator = "+" | "-" . +MultiplicativeExpression = PipeExpression + | MultiplicativeExpression MultiplicativeOperator PipeExpression . +MultiplicativeOperator = "*" | "/" . PipeExpression = PostfixExpression | PipeExpression PipeOperator UnaryExpression . PipeOperator = "|>" . diff --git a/content/v2.0/reference/flux/language/lexical-elements.md b/content/v2.0/reference/flux/language/lexical-elements.md index de69f63a1..f2cb39294 100644 --- a/content/v2.0/reference/flux/language/lexical-elements.md +++ b/content/v2.0/reference/flux/language/lexical-elements.md @@ -60,14 +60,12 @@ longIdentifierName The following keywords are reserved and may not be used as identifiers: ``` -and import not return option +and import not return option test empty in or package builtin ``` {{% note %}} To be implemented: [IMPL#256](https://github.com/influxdata/platform/issues/256) Add in and empty operator support. - -To be implemented: [IMPL#334](https://github.com/influxdata/platform/issues/334) Add "import" support {{% /note %}} diff --git a/content/v2.0/reference/flux/language/packages.md b/content/v2.0/reference/flux/language/packages.md index f076cc060..73c7c9721 100644 --- a/content/v2.0/reference/flux/language/packages.md +++ b/content/v2.0/reference/flux/language/packages.md @@ -58,7 +58,8 @@ The `main` package is special for a few reasons: Packages are initialized in the following order: 1. All imported packages are initialized and assigned to their package identifier. -2. All option declarations are evaluated and assigned regardless of order. An option cannot have dependencies on any other options assigned in the same package block. +2. All option declarations are evaluated and assigned regardless of order. + An option cannot have a dependency on another option assigned in the same package block. 3. All variable declarations are evaluated and assigned regardless of order. A variable cannot have a direct or indirect dependency on itself. 4. Any package side effects are evaluated. diff --git a/content/v2.0/reference/flux/language/statements.md b/content/v2.0/reference/flux/language/statements.md index 77bb62c72..5ae6b94c0 100644 --- a/content/v2.0/reference/flux/language/statements.md +++ b/content/v2.0/reference/flux/language/statements.md @@ -86,7 +86,7 @@ A named type can be created using a type assignment statement. A named type is equivalent to the type it describes and may be used interchangeably. ```js -TypeAssignement = "type" identifier "=" TypeExpression +TypeAssignment = "type" identifier "=" TypeExpression TypeExpression = identifier | TypeParameter | ObjectType From dac86cda57c28af88b420480eeb8e3b697b46030 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 13 Feb 2019 15:27:41 -0700 Subject: [PATCH 3/4] added bucket name to contains function example --- .../v2.0/reference/flux/functions/built-in/tests/contains.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.0/reference/flux/functions/built-in/tests/contains.md b/content/v2.0/reference/flux/functions/built-in/tests/contains.md index 75e670986..be4fbd634 100644 --- a/content/v2.0/reference/flux/functions/built-in/tests/contains.md +++ b/content/v2.0/reference/flux/functions/built-in/tests/contains.md @@ -37,7 +37,7 @@ _**Data type:** Array of Booleans | Integers | UIntegers | Floats | Strings | Ti ```js fields = ["load1", "load5", "load15"] -from(bucket) +from(bucket: "example-bucket") |> range(start:start, stop: stop) |> filter(fn: (r) => r._measurement == "system" and From 0c93c2f5268e3703d2ef8aafe1806a7c19e94f9f Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Wed, 13 Feb 2019 15:41:41 -0700 Subject: [PATCH 4/4] added missing paramater data type on window function --- .../reference/flux/functions/built-in/transformations/window.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content/v2.0/reference/flux/functions/built-in/transformations/window.md b/content/v2.0/reference/flux/functions/built-in/transformations/window.md index f68d57351..fee6fc0b9 100644 --- a/content/v2.0/reference/flux/functions/built-in/transformations/window.md +++ b/content/v2.0/reference/flux/functions/built-in/transformations/window.md @@ -107,6 +107,8 @@ _**Data type:** String_ Specifies whether empty tables should be created. Defaults to `false`. +_**Data type:** Boolean_ + ## Examples #### Window data into 10 minute intervals