Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Remove variadic functions' optional args from the output of show functions #106454

Merged
merged 6 commits into from
Mar 20, 2024

Conversation

fang-xing-esql
Copy link
Member

Resolve #106346

The optional arguments of variadic functions are removed from optionalArgs, argNames and argTypes in the output of show functions, and the outputs are shown below.

The full signature of the functions are kept unchanged, with the optional arguments included, so that we can find the information of the optional arguments there. If needed the full signature can be changed too.

  "query": "show functions | where variadic | keep name, variadic, optionalArgs, argNames, argTypes"

     name      |   variadic    | optionalArgs  |     argNames     |                                                 argTypes                                                  
---------------+---------------+---------------+------------------+-----------------------------------------------------------------------------------------------------------
case           |true           |[false, false] |[condition, value]|[boolean, boolean|cartesian_point|date|double|geo_point|integer|ip|keyword|long|text|unsigned_long|version]
cidr_match     |true           |[false, false] |[ip, blockX]      |[ip, keyword]                                                                                              
coalesce       |true           |false          |expression        |boolean|text|integer|keyword|long                                                                          
concat         |true           |[false, false] |[string1, string2]|[keyword|text, keyword|text]                                                                               
greatest       |true           |false          |first             |integer|long|double|boolean|keyword|text|ip|version                                                        
least          |true           |false          |first             |integer|long|double|boolean|keyword|text|ip|version             

…argNames and argTypes for variadic functions
Copy link
Contributor

Documentation preview:

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Mar 19, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @fang-xing-esql. It looks much better. And it's a LGTM.

There is one more thing we can improve and make things more consistent: at the moment the naming of all the arguments is inconsistent.
For example, concat has string1 and string2 (which is ok) but other string manipulating functions have str and newStr.
Most of the numerical arguments are called n, but there are functions (min, max...) that receive numerical arguments called field.
There are also a lot of function that have a single argument called v.

Can you please have these consistent in some form? For example:

  • those arguments that are strings let's call them string, newString, string2 etc
  • all the string numerical arguments let's call them number
  • all the generic arguments, maybe field
    I am open to suggestions, as long as things are consistent.

Copy link
Contributor

@dej611 dej611 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just few minor comments

@fang-xing-esql
Copy link
Member Author

Thank you for reviewing @astefan @dej611 ! The above comments are all addressed.

@fang-xing-esql fang-xing-esql merged commit 5d05d81 into elastic:main Mar 20, 2024
14 checks passed
@lkts lkts mentioned this pull request Mar 21, 2024
@fang-xing-esql fang-xing-esql deleted the functioninfo branch March 25, 2024 13:23
drewdaemon added a commit to elastic/kibana that referenced this pull request May 24, 2024
…79584)

## Summary

Resolve #179634

This PR introduces a script to gather metadata from Elasticsearch and
build the function definitions for Kibana's client-side validation.

To run the script: `cd packages/kbn-esql-validation-autocomplete && yarn
makedefs path/to/elasticsearch/repo`

## Current limitations
### Things we can't (yet) gather from ES

#### Things that are currently being filled in on the Kibana side but
would be missing if we had to rely completely on ES
- function aliases (e.g. `to_str`)
- operators and aggs (issues for Elasticsearch
elastic/elasticsearch#107219 and
elastic/elasticsearch#107220)
- Kibana AST parameter settings
- `constantOnly` — whether a parameter can be a non-literal or not
(`percentile`, `auto_bucket`)
- `constantOptions`/`constantSuggestions` — specific information about
which constants are accepted or suggested for particular parameters.
- `supportsWildcard` — whether a parameter can contain `*` (only `count`
at the moment)
- `noNestingFunctions` — whether a parameter can contain nested
functions (used for all agg functions)
- Kibana date constant types
  - `chrono_literal`
  - `time_literal`

### Other considerations
- Asciidoc links need to be scrubbed (e.g. `Function
{wikipedia}/foo/bar[arccosine] returns blah blah`)
- As of elastic/elasticsearch#106454 some
descriptions reference outdated parameter names and some parameter names
are questionable:
<img width="600" alt="Screenshot 2024-03-28 at 1 07 16 PM"
src="https://github.com/elastic/kibana/assets/315764/3b9ab457-e9fd-4c5f-afb2-23ae769bb44a">

_parameter `n` is now called `number`, but the description still calls
it `n`... also, is `number` really the best name for the variable?_

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESQL: review FunctionInfo for all functions
4 participants