Skip to content

Commit 83899fd

Browse files
committed
ES|QL sample documentation
1 parent 4cda8c2 commit 83899fd

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
% This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
2+
3+
```esql
4+
FROM employees
5+
| KEEP emp_no
6+
| SAMPLE 0.05
7+
```
8+
9+
| emp_no:integer |
10+
| --- |
11+
| 10018 |
12+
| 10024 |
13+
| 10062 |
14+
| 10081 |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## `SAMPLE` [esql-sample]
2+
3+
::::{warning}
4+
This functionality is in technical preview and may be
5+
changed or removed in a future release. Elastic will work to fix any
6+
issues, but features in technical preview are not subject to the support
7+
SLA of official GA features.
8+
::::
9+
10+
The `SAMPLE` command samples a fraction of the table rows.
11+
12+
**Syntax**
13+
14+
```esql
15+
SAMPLE probability
16+
```
17+
18+
**Parameters**
19+
20+
`probability`
21+
: The probability that a row is included in the sample. The value must be between 0 and 1, exclusive.
22+
23+
**Examples**
24+
25+
:::{include} ../examples/sample.csv-spec/sampleForDocs.md
26+
:::

docs/reference/query-languages/esql/_snippets/lists/processing-commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [preview] [`LOOKUP JOIN`](../../commands/processing-commands.md#esql-lookup-join)
1010
* [preview] [`MV_EXPAND`](../../commands/processing-commands.md#esql-mv_expand)
1111
* [`RENAME`](../../commands/processing-commands.md#esql-rename)
12+
* [preview] [`SAMPLE`](../../commands/processing-commands.md#esql-sample)
1213
* [`SORT`](../../commands/processing-commands.md#esql-sort)
1314
* [`STATS`](../../commands/processing-commands.md#esql-stats-by)
1415
* [`WHERE`](../../commands/processing-commands.md#esql-where)

docs/reference/query-languages/esql/commands/processing-commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ mapped_pages:
5050
:::{include} ../_snippets/commands/layout/rename.md
5151
:::
5252

53+
:::{include} ../_snippets/commands/layout/sample.md
54+
:::
55+
5356
:::{include} ../_snippets/commands/layout/sort.md
5457
:::
5558

x-pack/plugin/esql/qa/testFixtures/src/main/resources/sample.csv-spec

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,28 @@ FROM employees
229229
is_expected:boolean
230230
true
231231
;
232+
233+
234+
example for docs
235+
required_capability: sample_v2
236+
237+
// tag::sampleForDocs[]
238+
FROM employees
239+
| KEEP emp_no
240+
| SAMPLE 0.05
241+
// end::sampleForDocs[]
242+
// Hardcode the sample values to work around the limitations of the CSV tests in the
243+
// presence of randomness, and be able to specify an expected result for the docs.
244+
| STATS emp_no = COUNT()
245+
| EVAL emp_no = [10018, 10024, 10062, 10081]
246+
| MV_EXPAND emp_no
247+
;
248+
249+
// tag::sampleForDocs-result[]
250+
emp_no:integer
251+
10018
252+
10024
253+
10062
254+
10081
255+
// end::sampleForDocs-result[]
256+
;

0 commit comments

Comments
 (0)