Skip to content

Commit aac1761

Browse files
nik9000leemthompo
andauthored
ESQL: Improve tests and docs for some functions (#107331)
This improves the tests and docs for a few functions, specifically `E`, `FLOOR`, `PI`, `POW`, and `ROUND`. The examples and tested signatures will get copied into the docs and kibana signatures. Co-authored-by: Liam Thompson <[email protected]>
1 parent 1f5e04b commit aac1761

File tree

46 files changed

+485
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+485
-307
lines changed

docs/reference/esql/functions/description/e.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
*Description*
44

5-
Eulers number.
5+
Returns {wikipedia}/E_(mathematical_constant)[Euler's number].

docs/reference/esql/functions/description/floor.asciidoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
*Description*
44

55
Round a number down to the nearest integer.
6+
7+
NOTE: This is a noop for `long` (including unsigned) and `integer`.
8+
For `double` this picks the closest `double` value to the integer
9+
similar to {javadoc}/java.base/java/lang/Math.html#floor(double)[Math.floor].

docs/reference/esql/functions/description/pi.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
*Description*
44

5-
The ratio of a circles circumference to its diameter.
5+
Returns the {wikipedia}/Pi[ratio] of a circle's circumference to its diameter.

docs/reference/esql/functions/description/pow.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
*Description*
44

5-
Returns the value of a base raised to the power of an exponent.
5+
Returns the value of `base` raised to the power of `exponent`.
6+
7+
NOTE: It is still possible to overflow a double result here; in that case, null will be returned.

docs/reference/esql/functions/description/round.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
*Description*
44

5-
Rounds a number to the closest number with the specified number of digits.
5+
Rounds a number to the closest number with the specified number of digits. Defaults to 0 digits if no number of digits is provided. If the specified number of digits is negative, rounds to the number of digits left of the decimal point.
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,4 @@
1-
[discrete]
2-
[[esql-e]]
3-
=== `E`
4-
5-
*Syntax*
6-
7-
[.text-center]
8-
image::esql/functions/signature/e.svg[Embedded,opts=inline]
9-
10-
*Description*
11-
12-
Returns {wikipedia}/E_(mathematical_constant)[Euler's number].
1+
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
132

143
*Example*
154

@@ -21,3 +10,4 @@ include::{esql-specs}/math.csv-spec[tag=e]
2110
|===
2211
include::{esql-specs}/math.csv-spec[tag=e-result]
2312
|===
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
2+
3+
*Example*
4+
5+
[source.merge.styled,esql]
6+
----
7+
include::{esql-specs}/math.csv-spec[tag=floor]
8+
----
9+
[%header.monospaced.styled,format=dsv,separator=|]
10+
|===
11+
include::{esql-specs}/math.csv-spec[tag=floor-result]
12+
|===
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
2+
3+
*Example*
4+
5+
[source.merge.styled,esql]
6+
----
7+
include::{esql-specs}/math.csv-spec[tag=pi]
8+
----
9+
[%header.monospaced.styled,format=dsv,separator=|]
10+
|===
11+
include::{esql-specs}/math.csv-spec[tag=pi-result]
12+
|===
13+
Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
1-
[discrete]
2-
[[esql-pow]]
3-
=== `POW`
4-
5-
*Syntax*
6-
7-
[.text-center]
8-
image::esql/functions/signature/pow.svg[Embedded,opts=inline]
9-
10-
*Parameters*
11-
12-
`base`::
13-
Numeric expression. If `null`, the function returns `null`.
14-
15-
`exponent`::
16-
Numeric expression. If `null`, the function returns `null`.
17-
18-
*Description*
19-
20-
Returns the value of `base` raised to the power of `exponent`. Both arguments
21-
must be numeric. The output is always a double. Note that it is still possible
22-
to overflow a double result here; in that case, null will be returned.
23-
24-
include::types/pow.asciidoc[]
1+
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
252

263
*Examples*
274

@@ -33,10 +10,8 @@ include::{esql-specs}/math.csv-spec[tag=powDI]
3310
|===
3411
include::{esql-specs}/math.csv-spec[tag=powDI-result]
3512
|===
36-
3713
The exponent can be a fraction, which is similar to performing a root.
3814
For example, the exponent of `0.5` will give the square root of the base:
39-
4015
[source.merge.styled,esql]
4116
----
4217
include::{esql-specs}/math.csv-spec[tag=powID-sqrt]
@@ -45,3 +20,4 @@ include::{esql-specs}/math.csv-spec[tag=powID-sqrt]
4520
|===
4621
include::{esql-specs}/math.csv-spec[tag=powID-sqrt-result]
4722
|===
23+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This is generated by ESQL's AbstractFunctionTestCase. Do no edit it. See ../README.md for how to regenerate it.
2+
3+
*Example*
4+
5+
[source.merge.styled,esql]
6+
----
7+
include::{esql-specs}/docs.csv-spec[tag=round]
8+
----
9+
[%header.monospaced.styled,format=dsv,separator=|]
10+
|===
11+
include::{esql-specs}/docs.csv-spec[tag=round-result]
12+
|===
13+

0 commit comments

Comments
 (0)