Skip to content

Commit b4c5f5b

Browse files
committed
docs
1 parent 4f58f3b commit b4c5f5b

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

docs/reference/esql/esql-commands.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ endif::[]
4646
* experimental:[] <<esql-lookup-join>>
4747
* experimental:[] <<esql-mv_expand>>
4848
* <<esql-rename>>
49+
* experimental:[] <<esql-sample>>
4950
* <<esql-sort>>
5051
* <<esql-stats-by>>
5152
* <<esql-where>>
@@ -70,6 +71,7 @@ include::processing-commands/limit.asciidoc[]
7071
include::processing-commands/lookup.asciidoc[]
7172
include::processing-commands/mv_expand.asciidoc[]
7273
include::processing-commands/rename.asciidoc[]
74+
include::processing-commands/sample.asciidoc[]
7375
include::processing-commands/sort.asciidoc[]
7476
include::processing-commands/stats.asciidoc[]
7577
include::processing-commands/where.asciidoc[]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[discrete]
2+
[[esql-sample]]
3+
=== `SAMPLE`
4+
5+
preview::[]
6+
7+
The `SAMPLE` command samples a fraction of the table rows.
8+
9+
**Syntax**
10+
11+
[source,esql]
12+
----
13+
SAMPLE probability
14+
----
15+
16+
*Parameters*
17+
18+
`probability`::
19+
The probability that a row is included in the sample. The value must be between 0 and 1, exclusive.
20+
21+
*Example*
22+
23+
[source.merge.styled,esql]
24+
----
25+
include::{esql-specs}/sample.csv-spec[tag=sampleForDocs]
26+
----
27+
[%header.monospaced.styled,format=dsv,separator=|]
28+
|===
29+
include::{esql-specs}/sample.csv-spec[tag=sampleForDocs-result]
30+
|===

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)