Skip to content

Commit 1c813a0

Browse files
committed
ES|QL sample documentation
1 parent 6998c96 commit 1c813a0

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
@@ -221,3 +221,28 @@ FROM employees
221221
is_expected:boolean
222222
true
223223
;
224+
225+
226+
example for docs
227+
required_capability: sample_v3
228+
229+
// tag::sampleForDocs[]
230+
FROM employees
231+
| KEEP emp_no
232+
| SAMPLE 0.05
233+
// end::sampleForDocs[]
234+
// Hardcode the sample values to work around the limitations of the CSV tests in the
235+
// presence of randomness, and be able to specify an expected result for the docs.
236+
| STATS emp_no = COUNT()
237+
| EVAL emp_no = [10018, 10024, 10062, 10081]
238+
| MV_EXPAND emp_no
239+
;
240+
241+
// tag::sampleForDocs-result[]
242+
emp_no:integer
243+
10018
244+
10024
245+
10062
246+
10081
247+
// end::sampleForDocs-result[]
248+
;

0 commit comments

Comments
 (0)