Commit graph

278 commits

Author SHA1 Message Date
Parker Timmins
bb3ff8e924
ESQL: add REPEAT string function (#109220)
Add support for the string manipulation function REPEAT(string, number). This function concatenates the string argument with itself the specified number of times. If number is 0 an empty string is returned. If number is less than 0, null is returned and a warning is logged. If number is less than 0 and is a constant, the query will fail without executing.
2024-06-04 16:32:43 -05:00
Luigi Dell'Aquila
5f6e8f687b
ES|QL: add MV_APPEND function (#107001)
Adding `MV_APPEND(value1, value2)` function, that appends two values
creating a single multi-value. If one or both the inputs are
multi-values, the result is the concatenation of all the values, eg.

```
MV_APPEND([a, b], [c, d]) -> [a, b, c, d]
```

~I think for this specific case it makes sense to consider `null` values
as empty arrays, so that~ ~MV_APPEND(value, null) -> value~ ~It is
pretty uncommon for ESQL (all the other functions, apart from
`COALESCE`, short-circuit to `null` when one of the values is null), so
let's discuss this behavior.~

[EDIT] considering the feedback from Andrei, I changed this logic and
made it consistent with the other functions: now if one of the
parameters is null, the function returns null
2024-06-05 03:42:29 +10:00
Luigi Dell'Aquila
21952c7e36
ES|QL: add geo tests for mv_dedupe (#109342)
Adding more unit tests for MV_DEDUPE function, covering geo_point,
geo_shape, cartesian_point and cartesian_shape. This also adds docs for
Kibana.

Fixes https://github.com/elastic/elasticsearch/issues/108982
2024-06-05 03:33:14 +10:00
Liam Thompson
2268e383e8
[DOCS][ESQL][8.14] Add API key based security model info for ESQL CCS (#109155)
Co-authored-by: Jake Landis <jake.landis@elastic.co>
2024-06-03 18:44:33 +02:00
Iván Cea Fontenla
f16f71e2a2
ESQL: Add ip_prefix function (#109070)
Added ESQL function to get the prefix of an IP. It works now with both
IPv4 and IPv6. For users planning to use it with mixed IPs, we may need
to add a function like "is_ipv4()" first.

**About the skipped test:** There's currently a "bug" in the
evaluators//functions that return null. Evaluators can't handle them.
We'll work on support for that in another PR. It affects other
functions, like `substring()`. In this function, however, it only
affects in "wrong" cases (Like an invalid prefix), so it has no impact.

Fixes https://github.com/elastic/elasticsearch/issues/99064
2024-05-29 10:23:45 -04:00
Luigi Dell'Aquila
a5b1848c14
ES|QL: more tests for coalesce() function (#109032)
Adding more unit tests for `coalesce()` function, in particular adding
tests for `ip`, `date` and spatial data types.

This also generates the right signatures for Kibana.

Related to https://github.com/elastic/elasticsearch/issues/108982
2024-05-27 04:36:06 -04:00
Alexander Spies
c5ac06a70c
Remove esql version from docs (#108933)
Follow-up to https://github.com/elastic/elasticsearch/pull/108919. The
latter needs to be merged first to have the docs tests pass, as it makes
the version parameter optional in requests.
2024-05-23 10:36:15 -04:00
Iván Cea Fontenla
212fc05808
Reapply "ESQL: Expose "_ignored" metadata field" (#108864) (#108871)
Expose "_ignored" metadata field in ESQL queries.

This is the same code merged here:
https://github.com/elastic/elasticsearch/pull/108770 Which got reverted
here: https://github.com/elastic/elasticsearch/pull/108864

It was reverted because of a test failure:
https://gradle-enterprise.elastic.co/s/dpi2eib2x2fj2
2024-05-22 07:06:04 -04:00
Alexander Spies
16a5d248b7
ESQL: Clone ql for esql (#108773)
Part of https://github.com/elastic/elasticsearch/issues/106679

* Copy the `ql` project into a different project _just for esql_, call it `esql-core`.
* Make `esql` depend only on the latter.
* Fix `EsqlNodeSubclassTests`; I'm confused why this didn't bite us earlier.
* Update the warning regexes in some csv tests as the exceptions have other package names now.

**Note to reviewers:** Exclude the first commit when viewing the diff,
as that contains only the actual copying of `ql`. The remaining commits
are the actually meaningful ones. _The `build.gradle` files probably
require the most attention._
2024-05-22 04:35:17 -04:00
Iván Cea Fontenla
04f1fcee51
Revert "ESQL: Expose "_ignored" metadata field" (#108864)
Reverting after tests failure:
https://gradle-enterprise.elastic.co/s/dpi2eib2x2fj2

Reverts elastic/elasticsearch#108770
2024-05-21 11:22:27 -04:00
Iván Cea Fontenla
47370a15e6
ESQL: Expose "_ignored" metadata field (#108770)
Expose "_ignored" metadata field in ESQL queries
2024-05-21 07:32:32 -04:00
Liam Thompson
4e04bf19ce
[DOCS] Update Using ESQL in Kibana doc (#108715)
* [DOCS] Update Using ESQL in Kibana doc

* Add dashboard panel instructions,screenshots

* Add query history info, images

* Update enabling ESQL info
2024-05-17 12:36:04 +02:00
Bogdan Pintea
3b21ec8818
ESQL: Remove OPTIONS clause in FROM command (#108692)
This remove the `OPTIONS` clause of the `FROM` command.
2024-05-15 18:15:02 -04:00
Iván Cea Fontenla
62b372b4dc
ESQL: CBRT function (#108574)
- Added the cube root function to ESQL (`CBRT(x)`). Nearly identical to SQRT, but without the negative numbers exception
- Added docs generation support for Windows end lines (CRLF), as within the examples, it was writing the "\r" without the "\n" (Which was being converted to "\\n"), and some other inconsistencies
- Some updates to `package-info.java` documentation over how to create functions
- Fixes https://github.com/elastic/elasticsearch/issues/108675

Functions issue: https://github.com/elastic/elasticsearch/issues/98545
2024-05-15 16:50:15 +02:00
Fang Xing
172c05918c
[DOCS] ES|QL implicit casting (#108618)
* implicit casting doc
2024-05-15 09:07:09 -04:00
Fang Xing
11de886346
[ES|QL] Add/Modify annotations for spatial and conditional functions for better doc generation (#107722)
* annotation for spatial functions and conditional functions
2024-05-10 14:49:25 -04:00
Luigi Dell'Aquila
fed808850d
ES|QL: Add unit tests for now() function (#108498) 2024-05-10 14:28:19 +02:00
Nik Everett
5a612d4100
ESQL: Remove remaining IT_tests_only (#108434)
This moves examples from files marked to run in integration tests only
to the files where they belong and disables this pattern matching. We
now use supported features.
2024-05-09 09:32:46 -04:00
Bogdan Pintea
8864058f83
ESQL: Add more time span units (#108300)
This adds `nanosecond`, `microsecond` and `quarter` to the set of
supported time spans. It also adds a few standard and common
abbreviations to some existing ones.
2024-05-08 08:51:02 -04:00
Liam Thompson
9b7e9b5d59
[DOCS] ESQL goes GA (#108342) 2024-05-07 14:12:50 +02:00
Bogdan Pintea
de725aef80
Add docs clarifications on DATE_DIFF args (#108301)
This adds some clarifications on the time unit strings the function
takes as arguments, noting the differences between these and the time
span literals, as well as the abbreviations' source.
2024-05-07 12:59:01 +02:00
Nik Everett
089fd7d7da
ESQL: Rework integration-only csv testing (#108313)
This reworks the integration-test-only csv testing for `metadata` to use
the `required_feature:` syntax instead of the `-IT_tests_only`
extension. This is a little more flexible and way nicer on the eyes.
2024-05-06 11:06:50 -04:00
Bogdan Pintea
b26d7d3e14
Introduce an IP functions group (#108304)
This takes the CIDR_MATCH out of the operators group and adds it to a
new `IP functions` group.
The change also re-aranges the groups, grouping together the
type-specific functions and ordering them alphabetically.
2024-05-06 13:43:30 +02:00
Fang Xing
4daac77e3b
[ES|QL] Add/Modify annotations for operators for better doc generation (#108220)
* annotation for operators
2024-05-03 22:59:51 -04:00
Bogdan Pintea
5f4ef87c47
Fix docs generation of signatures for variadic functions (#107865)
This fixes the generation of the signatures for variadic functions,
except for those that take a list as last argument; i.e.  functions with
optional arguments (like ROUND) or functions with overloading-like
signatures (like BUCKET).
2024-05-03 15:37:22 +02:00
Fang Xing
7ae08306a0
mv functions (#107839)
Add annotations for MV functions for better doc generation.
2024-05-01 10:47:22 -04:00
Bogdan Pintea
4b5c5e2ded
Update BUCKET docs in source (#108005)
This applies a review proposed changes to the source, so that they're
synchronized to the generated output.
2024-04-29 14:27:20 +02:00
Nhat Nguyen
22aad7b201
Support metrics counter types in ESQL (#107877)
This commit adds support for numeric metrics counter fields in ES|QL. 
These counter types, including counter_long, counter_integer, and
counter_double, are different from their parent types. Users will have
limited interaction with these counter types, restricted to:

- Retrieving values without any processing
- Casting to their root type (e.g., to_long(a_long_counter))
- Using them in the metrics rate aggregation

These restrictions are intentional to prevent misuse. If users want to 
use them as numeric values, explicit casting to their root types is
required.
2024-04-26 12:15:48 -07:00
Bogdan Pintea
a21242054b
ESQL: Document BUCKET as a grouping function (#107864)
This adds the documentation for BUCKET as a grouping function and the
addition of the "direct" invocation mode providing a span (in addition
to the auto mode).
2024-04-25 12:38:12 -04:00
Bogdan Pintea
7af45cc52e
ESQL: Document the cast operator (::) (#107871)
This documents the cast operator, `::`.
2024-04-25 10:10:59 -04:00
Bogdan Pintea
31f2fb85df
Docs: move STARTS/ENDS_WITH under string functions in the docs (#107867)
This moves the STARTS_WITH and ENDS_with under the strings functions
section (as they're not operators).
2024-04-25 09:41:11 -04:00
Bogdan Pintea
9482673fbe
Docs: move base64 functions under string functions (#107866)
This moves the TO_BASE64 and FROM_BASE64 from the type conversion
functions under string functions (they take a string as input and output
another string).
2024-04-25 13:57:45 +02:00
Fang Xing
ad15d50863
[ES|QL] more doc generation via annotations (#107541)
Annotations for math functions, datetime functions, string functions, type conversion functions.
2024-04-22 14:43:36 -04:00
Mark Tozzi
f620961812
[ESQL] Add in the autogenerated docs for a bunch of functions (#107633) 2024-04-18 14:09:30 -04:00
Liam Thompson
33a71e3289
[DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413)
* Remove `es-test-dir` book-scoped variable

* Remove `plugins-examples-dir` book-scoped variable

* Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables

- In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed.
- In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path
- In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem

* Replace `es-repo-dir` with `es-ref-dir`

* Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
2024-04-17 14:37:07 +02:00
Liam Thompson
84f1b26953
Update esql-version.asciidoc (#107547)
Fix heading misalignment and typo.
2024-04-17 09:54:56 +02:00
Bogdan Pintea
a2c2e8fe47
ESQL: extend BUCKET with spans. Turn it into a grouping function (#107272)
This extends `BUCKET` function to accept a two-parameters-only
invocation: the first parameter remains as is, while the second is a
span. It can be a numeric (floating point) span, if the first argument
is numeric, or a date period or time duration, if the first argument is
a date.

Also, the function can now be invoked with the alias BIN.

Additionally, the function has been turned into a grouping-only function
and thus can only be used within a `STATS` command.
2024-04-16 12:57:18 +02:00
Fang Xing
353abef214
[ES|QL] Base64 decoding and encoding functions (#107390)
* add base64 functions
2024-04-15 18:39:26 -04:00
Alexander Spies
71b276da90
ESQL: Add version to docs (#107225)
Docs for https://github.com/elastic/elasticsearch/pull/106824.

Does not cover the [REST API
specs](https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/api/esql.query.json)
as these don't cover the request body.
2024-04-15 10:50:00 -04:00
Nik Everett
aac17616a3
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 <32779855+leemthompo@users.noreply.github.com>
2024-04-11 12:41:56 -04:00
Fang Xing
0075c1fb1e
[ES|QL] String literal implicit casting (#106932)
* string literal casting for scalar functions and arithmetic operations.
2024-04-10 21:20:12 -04:00
Craig Taverner
d915b964ba
Rename ST_CENTROID to ST_CENTROID_AGG (#107226)
* Rename ST_CENTROID to ST_CENTROID_AGG

In order to allow development of a scalar ST_CENTROID function.

* Fix table alignment
2024-04-10 17:56:45 +02:00
Liam Thompson
943885d0cd
[DOCS][ESQL] Render locate function docs (#107305) 2024-04-10 15:12:20 +02:00
Bogdan Pintea
8bcbc97128
Rename generated docs for (renamed) BUCKET func (#107299)
This checks in the generated-by-test doc files for newly renamed BUCKET
function.
2024-04-10 06:50:12 -04:00
Bogdan Pintea
d6f9d1e69e
ESQL: Rename AUTO_BUCKET to just BUCKET (#107197)
This renames the function AUTO_BUCKET to just BUCKET.
It also removes the experimental tagging of the function in the docs, making it generally available.
2024-04-10 12:21:08 +02:00
Nik Everett
96227a1970
ESQL: Generate kibana inline docs (#106782)
This takes a stab at generating the markdown files that Kibana uses for
its inline help. It doesn't include all of the examples because the
`@Example` annotation is not filled in - we're tracking that in
https://github.com/elastic/elasticsearch/issues/104247#issuecomment-2018944371

There are some links in the output and they are in markdown syntax. We
should figure out how to make them work for kibana.
2024-04-09 14:19:48 -04:00
Nik Everett
aba7566409
ESQL: Better tests to AUTO_BUCKET (#107228)
This improves the tests for AUTO_BUCKET marginally, specifically so that
it tests all valid combinations of arguments and generates a correct
types table. This'll combine nicely with #106782 to generate the
signatures that kibana needs for it's editor.
2024-04-09 12:22:15 -04:00
Liam Thompson
3dccc66c2c
[DOCS][ESQL] Rename _Learning ESQL_ to _ESQL reference_ (#107259) 2024-04-09 14:16:24 +02:00
Liam Thompson
c1ef120fe2
[Docs][ESQL] Make functions reference more digestible (#107258)
* [Docs][ESQL] Make functions reference more digestible

* Remove redundant links
2024-04-09 14:15:54 +02:00
Luigi Dell'Aquila
2588c72a52
ES|QL: Add unit tests and docs for DATE_TRUNC() (#107145) 2024-04-09 10:41:34 +02:00