Skip to content

Conversation

@nik9000
Copy link
Member

@nik9000 nik9000 commented Aug 20, 2023

Adds package javadoc for ESQL's function.scalar package with instructions on how to write a function.

Adds package javadoc for ESLQ's `function.scalar` package with
instructions on how to write a function.
@nik9000 nik9000 added >docs General docs changes :Analytics/ES|QL AKA ESQL v8.11.0 labels Aug 20, 2023
@nik9000 nik9000 requested review from astefan and costin August 20, 2023 17:23
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@elasticsearchmachine elasticsearchmachine added Team:Docs Meta label for docs team Team:QL (Deprecated) Meta label for query languages team labels Aug 20, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

@nik9000
Copy link
Member Author

nik9000 commented Aug 20, 2023

This renders as:
image

Though I expect most folks will read it in javadoc form.

Copy link
Contributor

@alex-spies alex-spies 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, only one minor remark regarding formatting.

* <li>Fork the <a href="github.com/elastic/elasticsearch">Elasticsearch repo</a>.</li>
* <li>Clone your fork locally.</li>
* <li>Add Elastic's remote, it should look a little like:
* {@code<pre>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is rendered correctly in the docs; the <pre> tag is printed verbatim and everything is squished into one line, going by your screenshot. I guess the tag needs to be outside the {@code ... } block?

Also applies in other sections below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also applies in other sections below.

Ah! I was mostly checking within intellij and just quickly eyeballed the screenshot. I'll fix.

* </li>
* <li>
* Find a function in this package similar to the one you are working on and copy it to build
* yours. There's come ceremony required in each function class to make it constant foldable
Copy link
Contributor

Choose a reason for hiding this comment

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

There's come -> There's some

* serializable over the wire. Mostly you can copy existing implementations for both.
* </li>
* <li>
* Rerun the {@code CsvTests}. They should find your function and maybe even pass. Add a
Copy link
Contributor

Choose a reason for hiding this comment

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

Imo, we should instruct authors to also consider one-two more complex tests with the newly added functions (functions passed as parameters to other functions for example), these types of queries can sometimes reveal some flaws in optimization rules, or indicate that some core methods of that specific function were not implemented/overriden or poorly implemented.

* {@code<pre>./gradlew -p x-pack/plugin/esql/ spotlessApply</pre>}
* </li>
* <li>
* Now you can run all of the ESQL tests liks CI:
Copy link
Contributor

Choose a reason for hiding this comment

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

tests liks CI -> tests like CI

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.

Looking good. Left some minor comments.

@nik9000 nik9000 added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Aug 21, 2023
Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM.

P.S. What's ESLQ? :)

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

LGTM, just one noteworthy suggestion.

* an {@link org.elasticsearch.compute.operator.EvalOperator.ExpressionEvaluator} implementation
* calling the method annotated with {@link org.elasticsearch.compute.ann.Evaluator}.
* <li>
* Once your evaluator is generated you can implement {@link org.elasticsearch.xpack.esql.planner.Mappable#toEvaluator},
Copy link
Contributor

Choose a reason for hiding this comment

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

Past #98628:

Suggested change
* Once your evaluator is generated you can implement {@link org.elasticsearch.xpack.esql.planner.Mappable#toEvaluator},
* Once your evaluator is generated you can implement {@link org.elasticsearch.xpack.esql.evaluator.mapper.EvaluatorMapper#toEvaluator},

Comment on lines +85 to +86
* Now it's time to make a unit test! The infrastructure for these is under some flux at
* the moment, but it's good to extend from {@code AbstractScalarFunctionTestCase}. All of
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Now it's time to make a unit test! The infrastructure for these is under some flux at
* the moment, but it's good to extend from {@code AbstractScalarFunctionTestCase}. All of
* Now it's time to make a unit test! The infrastructure for these might change, but it's good to extend from {@code AbstractScalarFunctionTestCase}. All of

While admittedly everything about this guide might change, it's likely we'll forget to update this sentence short term and this will remain in flux for a longer while.

* isn't a strong guiding principle in the theme.
* </li>
* <li>
* Rerun the {@code CsvTests} and watch your new test fail. Yay, TDD doing it's job.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Rerun the {@code CsvTests} and watch your new test fail. Yay, TDD doing it's job.
* Rerun the {@code CsvTests} and watch your new test fail. Yay, TDD FTW.

😎

@elasticsearchmachine elasticsearchmachine merged commit 5fb68d5 into elastic:main Aug 22, 2023
@nik9000 nik9000 deleted the function_howto branch August 22, 2023 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >docs General docs changes Team:Docs Meta label for docs team Team:QL (Deprecated) Meta label for query languages team v8.11.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants