Commit Graph

41 Commits

Author SHA1 Message Date
Nik Everett 649ceb74ab
ESQL docs: generate references for functions (#98856)
This generates a "railroad diagram" svg image that can be embedded into
the docs for any function to explain it's syntax. It's basic, but it's
something we can iterate on.

It also generates a table of supported types from the list of types that
we test. It can be included in the docs for reference as well.
2023-08-25 09:07:25 -04:00
Nik Everett 65ea90d3fd
ESQL: LEAST and GREATEST functions (#98630)
Adds `LEAST` and `GREATEST` functions to find the min or max of the
values in many columns.
2023-08-22 14:15:04 -04:00
Bogdan Pintea 372458c9fd
ESQL: date_trunc(): swap order of arguments (#98624)
Swap arguments order so that the range parameter is first and datetime
one second, inline with other languages.
2023-08-22 18:20:05 +02:00
Nik Everett 44e61341f2
ESQL: COALESCE function (#98542)
This adds a `COALESCE` function that returns the first non-null value.
2023-08-17 13:51:44 -04:00
Nik Everett a380e8c369
ESQL: LTRIM, RTRIM and fix unicode whitespace (#98590)
Here we add support for the following two ESQL functions:
* LTRIM: remove leading spaces from a string
* RTRIM: remove trailing spaces from a string

We also fix an issue with the handling of unicode white spaces. We
make use of unicode code points to identify unicode whitespace
characters instead of relying on ASCII codes.

Moreover, iterating bytes in a Unicode string needs to consider
that some Unicode characters are encoded using multiple bytes.
2023-08-17 11:30:12 -04:00
Craig Taverner aad16b7d6b
Simple ESQL pow() docs fixes after re-reviewing (#98601) 2023-08-17 17:29:06 +02:00
Andrei Stefan 014bd33f45
ESQL: replace the is_null function with IS NULL and IS NOT NULL predicates (#98412) 2023-08-16 20:19:40 +03:00
Kostas Krikellas b498ce9ff4
`Sqrt` function for ESQL (#98449)
* Sqrt function for ESQL

Introduces a unary scalar function for square root, which is a thin
wrapper over the Java.Math implementation.

* Fix area for ESQL integration changelog.

* Restore changelog.

* Restore area in changelog.
2023-08-16 16:33:30 +03:00
Nik Everett 24b2d16f95 Add `to_degrees` and `to_radians` functions (ESQL-1496)
This adds the `to_degrees` and `to_radians` functions. It uses the
"convert" function framework because that just felt right - these
convert between radians and degrees after all.
2023-08-03 04:23:15 +10:00
Nik Everett c1601f5a9c Add remaining trigonometric functions (ESQL-1518)
Adds the remaining trigonomentric functions, `ACOS`, `ASIN`, `ATAN`, and
`ATAN2`.

---------

Co-authored-by: Bogdan Pintea <pintea@mailbox.org>
2023-08-03 01:12:10 +10:00
Nik Everett c44a245cae Add trigonometric functions (ESQL-1513)
This adds `SIN`, `COS`, `TAN`, `SINH`, `COSH`, and `TANH` functions.

---------

Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
2023-08-01 14:36:55 -04:00
Nik Everett 6c87075564 Support `auto_bucket` for numeric fields (ESQL-1494)
This adds support for numeric fields to `auto_bucket` and adds a new
`floor` function to round numeric down to the nearest integer. That
function is exposed because it's probably useful. I added it in this PR
because `auto_bucket` uses it as an implementation detail as well.
2023-07-31 16:45:59 -04:00
Craig Taverner 9e566c9068 Update docs/reference/esql/functions/pow.asciidoc
Co-authored-by: Bogdan Pintea <pintea@mailbox.org>
2023-07-24 15:50:13 +02:00
Craig Taverner 75ea3ab3cd Numerical overflow should result in `null` and a warning
To implement this we:

* Cast both arguments to double
* Perform integer and long validation on the double results before casting back to integer or long
* Perform a special case validation for exponent==1
* Any validation failures result in ArithmeticException, which is caught and added to warnings
2023-07-20 19:03:29 +02:00
Craig Taverner 925bdf49a8 Improve documentation for pow function and refined type rules 2023-07-20 11:32:09 +02:00
Luigi Dell'Aquila 95d9fd75ed Add date_extract function (ESQL-1346) 2023-07-19 14:08:06 +02:00
Abdon Pijpelink d204de411b Merge pull request ESQL-1393 from abdonpijpelink/es-pipe-ql
[DOCS] Change ESQL into ES|QL and other docs improvements
2023-07-11 10:07:18 +02:00
Martijn van Groningen b259248568 Reused example from spec file 2023-07-10 10:17:12 +02:00
Martijn van Groningen c406b64058 use ROW in docs and added test with ROWS 2023-07-07 20:57:39 +02:00
Martijn van Groningen 3c3963cc28 Add trim function
This change adds a string `trim` function.
2023-07-07 17:37:38 +02:00
Abdon Pijpelink 68b74bea34 Move IS_NULL, POW, ROUND, STARTS_WITH, SUBSTRING code snippets to CSV files 2023-07-07 15:45:06 +02:00
Mark Tozzi 985b1949cb Log base 10 for ESQL (ESQL-1358)
Introduces a unary scalar function for base 10 log, which is a thin
wrapper over the Java.Math implementation

---------

Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
2023-07-06 15:37:35 -04:00
Nik Everett f3b20067a3 Add `PI` and `TAU` functions (ESQL-1357)
Adds functions for the constants `PI` and it's big brother `TAU`.
2023-07-05 16:06:06 -05:00
Bogdan Pintea 48cb069670 Add unsigned_long type support (ESQL-1289)
This adds support for the `unsigned_long` type.
The type can be now used with the defined math function, both scalar and
MV'ed, arithmetic and binary comparison ones.
The `to_unsigned_long()` conversion function is also added.
2023-07-04 15:45:10 +02:00
Nik Everett 1a1941913d Implement `MV_DEDUPE` (ESQL-1287)
This implements the `MV_DEDUPE` function that removes duplicates from
multivalues fields. It wasn't strictly in our list of things we need in
the first release, but I'm grabbing this now because I realized I needed
very similar infrastructure when I was trying to build grouping by
multivalued fields. In fact, I realized that I could use our
stringtemplate code generation to generate most of the complex parts.
This generates the actual body of `MV_DEDUPE`'s implementation and the
body of the `Block` accepting `BlockHash` implementations. It'll be
useful in the final step for grouping by multivalued fields.

I also got pretty curious about whether the `O(n^2)` or `O(n*log(n))`
algorithm for deduplication is faster. I'd been assuming that for all
reasonable sized inputs the `O(n^2)` bubble sort looking selection
algorithm was faster. So I measured it. And it's mostly true - even for
`BytesRef` if you have a dozen entries the selection algorithm is
faster. Lower overhead and stuff. Anyway, to measure it I had to
implement the copy-and-sort `O(n*log(n))` algorithm. So while I was
there I plugged it in and selected it in cases where the number of
inputs is large and the selection alogorithm is likely to be slower.
2023-06-27 08:13:19 -05:00
Luigi Dell'Aquila c2c0b0fa0d Implement now() function (ESQL-1172)
returns current datetime
2023-06-27 12:01:09 +02:00
Nik Everett 35fddc2281 Create e() function (ESQL-1304)
Euler's number.
2023-06-22 10:02:23 -04:00
Luigi Dell'Aquila 100ca0acca Rename PROJECT command to KEEP (ESQL-1282) 2023-06-19 13:06:44 +02:00
Nik Everett 1f383f3cd2 Docs: compress results into query (ESQL-1259)
This compresses the results and the query on the page to take up less
space and make them more obviously connected.
2023-06-12 09:37:45 -05:00
Bogdan Pintea 1e268fa0f0 Introduce `version` type support (ESQL-1218)
This adds support for the type `version`.
The conversion function `to_version()` has also beed added;
`to_string()` now supports the type as well.
2023-06-06 10:39:51 +10:00
Bogdan Pintea 33776045f6 Add docs for the conversion functions (ESQL-1217)
Add docs for the `to_xxx()` conversion functions.

---------

Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
2023-06-06 01:32:14 +10:00
Nik Everett be7e182a6c Rename mv_join to mv_concat (ESQL-1213)
That's not the name SPL uses for this, but it's a much more intuitive
name.

Closes ESQL-1210
2023-06-01 05:48:04 +10:00
Nik Everett 024217ba27 Docs for `auto_bucket` (ESQL-1208)
This adds some docs for the `auto_bucket` command.

---------

Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
2023-06-01 03:49:39 +10:00
Nik Everett 64e41ef100 Add `mv_join` function (ESQL-1166)
Adds an `mv_join` function that joins together multivalue string fields.
You can combine this with out fancy new `to_string` to join together any
multivalued fields into a string.
2023-05-25 02:32:23 +10:00
Nik Everett efe8bdef3a Add `mv_median` function (ESQL-1164)
This adds a `mv_median` function that converts a multivalued field into
a single valued field by picking the median. If there are an even number
of values we return the average of the middle two numbers. If the input
type is `int` or `long` then the average rounds *down*.
2023-05-23 17:01:08 -04:00
Nik Everett 75a6ac1ed1 Docs: convert the results into a table (ESQL-1143)
This moves the results in the esql examples from preformatted text to an
actual html table. We can further format it from there.
2023-05-17 16:00:15 -04:00
Nik Everett b7b9f71a49 Implement `mv_count` (ESQL-1126)
Implements the `mv_count` function which returns a count of the values
in a column.
2023-05-12 15:57:49 -04:00
Abdon Pijpelink 35356b86a2 Move each function to its own file 2023-05-11 17:02:27 +02:00
Nik Everett 555781a8a0 Docs for remaining mv functions (ESQL-1114)
This adds docs for all of the remaining `mv_*` functions that have been
implemented at this point.
2023-05-11 07:03:58 -04:00
Nik Everett ce1d634d77 Docs for `mv_min` (ESQL-1092)
This adds docs for the `mv_min` function. It uses an as yet unsupported
syntax, `ROW a=[2,1]`, but I think we'll support it before long.
2023-05-10 17:26:59 -04:00
Nik Everett 87e6fcc948 Docs for `split` (ESQL-1084)
This adds docs for the new `split` function.
2023-05-04 06:26:48 -04:00