Add documentation about addMap, addSort, addUnwindow, and addWindow
Signed-off-by: David Arendsen <darendsen@gamepoint.com>
This commit is contained in:
parent
e0cf376f6f
commit
b7e0b21c8f
9 changed files with 179 additions and 27 deletions
|
|
@ -11,13 +11,17 @@ or [fromBucket()](functions/fromBucket.md)
|
||||||
* [addDuplicate()](functions/addDuplicate.md)
|
* [addDuplicate()](functions/addDuplicate.md)
|
||||||
* [addFieldFilter()](functions/addFieldFilter.md)
|
* [addFieldFilter()](functions/addFieldFilter.md)
|
||||||
* [addGroup()](functions/addGroup.md)
|
* [addGroup()](functions/addGroup.md)
|
||||||
|
* [addLast()](functions/addLast.md)
|
||||||
* [addLimit()](functions/addLimit.md)
|
* [addLimit()](functions/addLimit.md)
|
||||||
|
* [addMap()](functions/addMap.md)
|
||||||
* [addMean()](functions/addMean.md)
|
* [addMean()](functions/addMean.md)
|
||||||
* [addRangeStart()](functions/addRangeStart.md)
|
* [addRangeStart()](functions/addRangeStart.md)
|
||||||
or [addRangeInBetween()](functions/addRangeInBetween.md)
|
or [addRangeInBetween()](functions/addRangeInBetween.md)
|
||||||
* [addReduce()](functions/addReduce.md)
|
* [addReduce()](functions/addReduce.md)
|
||||||
|
* [addSort()](functions/addSort.md)
|
||||||
* [addSum()](functions/addSum.md)
|
* [addSum()](functions/addSum.md)
|
||||||
* [addLast()](functions/addLast.md)
|
* [addUnwindow()](functions/addUnwindow.md)
|
||||||
|
* [addWindow()](functions/addWindow.md)
|
||||||
|
|
||||||
Anything missing here? You can use this method to add anything to the query:
|
Anything missing here? You can use this method to add anything to the query:
|
||||||
* [addRawFunction()](functions/addRawFunction.md)
|
* [addRawFunction()](functions/addRawFunction.md)
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Flux Query Builder Docs
|
||||||
|
|
||||||
|
## Functions » addMap()
|
||||||
|
|
||||||
|
### Parameters:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Required</th>
|
||||||
|
<th>Data type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>fn</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>Single argument function to apply to each record. The return value must be a record.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
->addMap('r with name: r.user')
|
||||||
|
```
|
||||||
|
|
||||||
|
This will result in the following Flux function part:
|
||||||
|
|
||||||
|
```
|
||||||
|
|> map(fn: (r) => ({ r with name: r.user }))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extra resources
|
||||||
|
|
||||||
|
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/map/)
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Flux Query Builder Docs
|
||||||
|
|
||||||
|
## Functions » addSort()
|
||||||
|
|
||||||
|
### Parameters:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Required</th>
|
||||||
|
<th>Data type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>columns</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>array</td>
|
||||||
|
<td>List of columns to sort by. Default is ["_value"].</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
->addSort(['column1', 'column2'], true)
|
||||||
|
```
|
||||||
|
|
||||||
|
This will result in the following Flux function part:
|
||||||
|
|
||||||
|
```
|
||||||
|
|> sort(columns: ["column1", "column2"], desc: true)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extra resources
|
||||||
|
|
||||||
|
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/sort/)
|
||||||
21
docs/functions/addUnwindow.md
Normal file
21
docs/functions/addUnwindow.md
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Flux Query Builder Docs
|
||||||
|
|
||||||
|
## Functions » addUnwindow()
|
||||||
|
|
||||||
|
Keeping aggregate values in separate tables generally isn’t the format in which you want your data. Use the window() function to “unwindow” your data into a single infinite (inf) window.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
->addUnwindow()
|
||||||
|
```
|
||||||
|
|
||||||
|
This will result in the following Flux function part:
|
||||||
|
|
||||||
|
```
|
||||||
|
|> window(every: inf)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extra resources
|
||||||
|
|
||||||
|
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/window/)
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
# Flux Query Builder Docs
|
||||||
|
|
||||||
|
## Functions » addWindow()
|
||||||
|
|
||||||
|
### Parameters:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Required</th>
|
||||||
|
<th>Data type</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>every</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>string</td>
|
||||||
|
<td>Duration of time between windows.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>options</td>
|
||||||
|
<td>No</td>
|
||||||
|
<td>array</td>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
period (string): <i>Duration of windows. Default is the 'every' value.</i>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
offset (string): <i>Duration to shift the window boundaries by. Default is '0s'.</i>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
location (string): <i>Location used to determine timezone. Default is the 'location' option.</i>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
timeColumn (string): <i>Column that contains time values. Default is '_time'.</i>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
startColumn (string): <i>Column to store the window start time in. Default is '_start'.</i>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
stopColumn (string): <i>Column to store the window stop time in. Default is '_stop'.</i>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
createEmpty (boolean): <i>Create empty tables for empty window. Default is false.</i>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
->addWindow('20s', [
|
||||||
|
'timeColumn' => '_time',
|
||||||
|
])
|
||||||
|
```
|
||||||
|
|
||||||
|
This will result in the following Flux function part:
|
||||||
|
|
||||||
|
```
|
||||||
|
|> window(every: 20s, timeColumn: "_time")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Extra resources
|
||||||
|
|
||||||
|
* [Flux documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/window/)
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Arendsen\FluxQueryBuilder\Builder;
|
|
||||||
|
|
||||||
class FluxPart
|
|
||||||
{
|
|
||||||
public const FROM = 'from';
|
|
||||||
public const MEASUREMENT = 'measurement';
|
|
||||||
public const RANGE = 'range';
|
|
||||||
public const FILTERS = 'filters';
|
|
||||||
public const REDUCE = 'reduce';
|
|
||||||
public const MAP = 'map';
|
|
||||||
public const SORT = 'sort';
|
|
||||||
public const GROUP = 'group';
|
|
||||||
public const LIMIT = 'limit';
|
|
||||||
public const WINDOW = 'window';
|
|
||||||
public const MEAN = 'mean';
|
|
||||||
public const DUPLICATE = 'duplicate';
|
|
||||||
public const UNWINDOW = 'unwindow';
|
|
||||||
public const AGGREGATEWINDOW = 'aggregateWindow';
|
|
||||||
public const RAWFUNCTION = 'raw';
|
|
||||||
}
|
|
||||||
|
|
@ -25,7 +25,7 @@ trait Universe
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addSort(array $columns, $desc): QueryBuilderInterface
|
public function addSort(array $columns = ['_value'], bool $desc = false): QueryBuilderInterface
|
||||||
{
|
{
|
||||||
$this->addToQuery(
|
$this->addToQuery(
|
||||||
new Sort($columns, $desc)
|
new Sort($columns, $desc)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class Sort extends Base
|
||||||
*/
|
*/
|
||||||
private $desc;
|
private $desc;
|
||||||
|
|
||||||
public function __construct(array $columns, bool $desc = false)
|
public function __construct(array $columns = ['_value'], bool $desc = false)
|
||||||
{
|
{
|
||||||
$this->columns = $columns;
|
$this->columns = $columns;
|
||||||
$this->desc = $desc;
|
$this->desc = $desc;
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@ final class QueryBuilderTest extends TestCase
|
||||||
],
|
],
|
||||||
'addWindow' => [
|
'addWindow' => [
|
||||||
'addWindow',
|
'addWindow',
|
||||||
['20s'],
|
['20s', ['timeColumn' => '_time']],
|
||||||
'|> window(every: 20s) '
|
'|> window(every: 20s, timeColumn: "_time") '
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue