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] Annotate all functions #103686

Merged
merged 27 commits into from
Jan 11, 2024

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Dec 22, 2023

Annotate all functions to have full signature available in SHOW FUNCTIONS.

Fixes #99853 and part of #100621

All available functions are now correctly annotated with types, and an additional isAggregation column has been added to the returned table.

Few assumptions made for the annotations:

  • all functions who accept text now have arguments of type keyword|text, unless they accepts enum strings in which case I've used the keyword type only.
  • in the case described above, I've tried to annotate as argument description the possible values (see date_extract)
  • I had to slightly tweak some description copy changing from commas to semi-colon as there's a bug in the CSV parser used in tests (thanks @luigidellaquila for debugging this) cc @abdonpijpelink

There are few notable exceptions to the annotation completeness who I have not been able to fix, so I've partially annotated them:

  • coalesce
  • mv_sum updated with recent main commit.
  • round
  • mv_dedupe

I'll create a separate issue for them.

@elasticsearchmachine elasticsearchmachine added v8.13.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Dec 22, 2023
@dej611 dej611 marked this pull request as ready for review January 10, 2024 14:47
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 10, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

How thoughtful! Thanks so much for this. I've left a small comment about your change to the length tests, but otherwise it's great.

I admit I haven't looked super closely at the words, but just having words is a huge improvement over where we are.

new TestCaseSupplier("6 bytes, 2 code points", () -> makeTestCaseAsKeyword("❗️", 2)),
new TestCaseSupplier("100 random alpha", () -> makeTestCaseAsKeyword(randomAlphaOfLength(100), 100)),
new TestCaseSupplier("100 random code points", () -> makeTestCaseAsKeyword(randomUnicodeOfCodepointLength(100), 100)),
new TestCaseSupplier("ascii string as text", () -> makeTestCaseAsText("clump", 5))
Copy link
Member

Choose a reason for hiding this comment

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

I suppose we could make both text and keyword in the function and return both.

It tends to be easier to do:

List<TestCase> cases = new ArrayList<>();
cases.addAll(makeTestCases("empty string", 0,  () -> ""));
cases.addAll(makeTestCases("100 random alpha", 100, () -> randomAlphaOfLength(100)));

I used to do with the List.of but for these it's just a pain.

Copy link
Contributor Author

@dej611 dej611 Jan 10, 2024

Choose a reason for hiding this comment

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

I see what you mean, so makeTestCases would produce two tests. Ok, I'll update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by cf5061a . Thanks @luigidellaquila for support and patience 😅 .

to_ver |"version to_ver(v:keyword|text|version)" |v |"keyword|text|version" | |version | |false |false
to_version |"version to_version(v:keyword|text|version)" |v |"keyword|text|version" | |version | |false |false
trim |"keyword|text trim(str:keyword|text)" |str |"keyword|text" | "" |"keyword|text" |Removes leading and trailing whitespaces from a string.| false | false
name:keyword | synopsis:keyword | argNames:keyword | argTypes:keyword | argDescriptions:keyword |returnType:keyword | description:keyword | optionalArgs:boolean | variadic:boolean | isAggregation:boolean
Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry for how this test ends up looking. It's quite a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was surprised to see that there's no update task for this kind of snapshot tests. I think it would be feasible to create one.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. I do these one at a time so I just manage it by hand. It isn't like this blob is really code reviewable either.

I do think we should do something about this. Or at least think about it.

@@ -63,6 +63,7 @@ public List<List<Object>> values(FunctionRegistry functionRegistry) {
row.add(signature.description());
row.add(collect(signature, EsqlFunctionRegistry.ArgSignature::optional));
row.add(signature.variadic());
row.add(signature.isAggregation());
Copy link
Member

Choose a reason for hiding this comment

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

@luigidellaquila is this one ok with you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, absolutely fine

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

"cartesian_point" }
"text",
"unsigned_long",
"version" }
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can write a checkstyle rule that forces these to be alphabetical!

Copy link
Contributor

@luigidellaquila luigidellaquila left a comment

Choose a reason for hiding this comment

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

LGTM, thank you very much Marco!

@dej611 dej611 merged commit 3145e9f into elastic:main Jan 11, 2024
15 checks passed
abdonpijpelink added a commit to abdonpijpelink/elasticsearch that referenced this pull request Jan 15, 2024
abdonpijpelink added a commit that referenced this pull request Jan 25, 2024
* Functions E-Z

* Incorporate changes from #103686

* More functions

* More functions

* Update docs/reference/esql/functions/floor.asciidoc

Co-authored-by: Liam Thompson <[email protected]>

* Update docs/reference/esql/functions/left.asciidoc

Co-authored-by: Liam Thompson <[email protected]>

* Apply suggestions from code review

Co-authored-by: Alexander Spies <[email protected]>

* Review feedback

* Fix geo_shape description

* Change 'colum'/'field' into 'expressions'

* Review feedback

* One more

---------

Co-authored-by: Liam Thompson <[email protected]>
Co-authored-by: Alexander Spies <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
henningandersen pushed a commit to henningandersen/elasticsearch that referenced this pull request Jan 25, 2024
…04623)

* Functions E-Z

* Incorporate changes from elastic#103686

* More functions

* More functions

* Update docs/reference/esql/functions/floor.asciidoc

Co-authored-by: Liam Thompson <[email protected]>

* Update docs/reference/esql/functions/left.asciidoc

Co-authored-by: Liam Thompson <[email protected]>

* Apply suggestions from code review

Co-authored-by: Alexander Spies <[email protected]>

* Review feedback

* Fix geo_shape description

* Change 'colum'/'field' into 'expressions'

* Review feedback

* One more

---------

Co-authored-by: Liam Thompson <[email protected]>
Co-authored-by: Alexander Spies <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ES|QL] New show aggs command for stats supported functions
4 participants