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
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>
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.
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.
This adds docs for all of ESQL's aggregation functions. Hopefully from
here on out we can add the docs as we add new functions.
I've created a few tagged regions in the aggs docs themselves so we can
include them into the ESQL docs.
---------
Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
Describes how we fetch multivalued fields by default, return them as
json arrays, how the internal sort order is not guaranteed, how most
functions will turn them into null, and how some fields remove
duplicates on save.
---------
Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
I think it's a bit easier to deal with the files this way. They also
make a page per command so it lines up with the files which is nice.
Also I moved some of the examples into the docs. They were mostly there
already, but I linked them.
---------
Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
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.
This implements the `mv_expand` command that converts multivalued fields
into single valued fields by emitting one row per value and copying all
other fields.
---------
Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
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*.
This adds a super basic shell for the esql docs. You can build them with
the standard docs build commend:
```
../docs/build_docs --doc docs/reference/index.asciidoc \
--resource x-pack/docs/ --chunk 1 --open
```