commit
6c89c27df4
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
title: limit() function
|
title: limit() function
|
||||||
description: The `limit()` function limits the number of records in output tables to a fixed number (n).
|
description: The `limit()` function limits each output table to the first `n` records.
|
||||||
aliases:
|
aliases:
|
||||||
- /v2.0/reference/flux/functions/transformations/limit
|
- /v2.0/reference/flux/functions/transformations/limit
|
||||||
menu:
|
menu:
|
||||||
|
@ -8,18 +8,23 @@ menu:
|
||||||
name: limit
|
name: limit
|
||||||
parent: built-in-transformations
|
parent: built-in-transformations
|
||||||
weight: 401
|
weight: 401
|
||||||
|
related:
|
||||||
|
- /v2.0/reference/flux/functions/built-in/transformations/tail/
|
||||||
|
- https://docs.influxdata.com/influxdb/latest/query_language/data_exploration/#the-limit-and-slimit-clauses, InfluxQL LIMIT
|
||||||
---
|
---
|
||||||
|
|
||||||
The `limit()` function limits the number of records in output tables to a fixed number ([`n`](#n)).
|
The `limit()` function limits each output table to the first [`n`](#n) records.
|
||||||
One output table is produced for each input table.
|
The function produces one output table for each input table.
|
||||||
Each output table contains the first `n` records after the first `offset` records of the input table.
|
Each output table contains the first `n` records after the [`offset`](#offset).
|
||||||
If the input table has less than `offset + n` records, all records except the first `offset` ones are output.
|
If the input table has less than `offset + n` records, `limit()` outputs all records after the `offset`.
|
||||||
|
|
||||||
_**Function type:** Filter_
|
_**Function type:** Filter_
|
||||||
_**Output data type:** Object_
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
limit(n:10, offset: 0)
|
limit(
|
||||||
|
n:10,
|
||||||
|
offset: 0
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
@ -36,13 +41,10 @@ Defaults to `0`.
|
||||||
_**Data type:** Integer_
|
_**Data type:** Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
##### Output the first ten records in each table
|
||||||
```js
|
```js
|
||||||
from(bucket:"example-bucket")
|
from(bucket:"example-bucket")
|
||||||
|> range(start:-1h)
|
|> range(start:-1h)
|
||||||
|> limit(n:10, offset: 1)
|
|> limit(n:10)
|
||||||
```
|
```
|
||||||
|
|
||||||
<hr style="margin-top:4rem"/>
|
|
||||||
|
|
||||||
##### Related InfluxQL functions and statements:
|
|
||||||
[LIMIT](https://docs.influxdata.com/influxdb/latest/query_language/data_exploration/#the-limit-and-slimit-clauses)
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
---
|
||||||
|
title: tail() function
|
||||||
|
description: The `tail()` function limits each output table to the last `n` records.
|
||||||
|
menu:
|
||||||
|
v2_0_ref:
|
||||||
|
name: tail
|
||||||
|
parent: built-in-transformations
|
||||||
|
weight: 401
|
||||||
|
related:
|
||||||
|
- /v2.0/reference/flux/functions/built-in/transformations/limit/
|
||||||
|
---
|
||||||
|
|
||||||
|
The `tail()` function limits each output table to the last [`n`](#n) records.
|
||||||
|
The function produces one output table for each input table.
|
||||||
|
Each output table contains the last `n` records before the [`offset`](#offset).
|
||||||
|
If the input table has less than `offset + n` records, `tail()` outputs all records before the `offset`.
|
||||||
|
|
||||||
|
_**Function type:** Filter_
|
||||||
|
|
||||||
|
```js
|
||||||
|
tail(
|
||||||
|
n:10,
|
||||||
|
offset: 0
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
### n
|
||||||
|
The maximum number of records to output.
|
||||||
|
|
||||||
|
_**Data type:** Integer_
|
||||||
|
|
||||||
|
### offset
|
||||||
|
The number of records to skip at the end of a table table before limiting to `n`.
|
||||||
|
Defaults to `0`.
|
||||||
|
|
||||||
|
_**Data type:** Integer_
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
##### Output the last ten records in each table
|
||||||
|
```js
|
||||||
|
from(bucket:"example-bucket")
|
||||||
|
|> range(start:-1h)
|
||||||
|
|> tail(n:10)
|
||||||
|
```
|
Loading…
Reference in New Issue