Skip to content

ES|QL: make capabilities an enum#109935

Merged
elasticsearchmachine merged 7 commits intoelastic:mainfrom
luigidellaquila:esql/safe_capabilities_registration
Jun 21, 2024
Merged

ES|QL: make capabilities an enum#109935
elasticsearchmachine merged 7 commits intoelastic:mainfrom
luigidellaquila:esql/safe_capabilities_registration

Conversation

@luigidellaquila
Copy link
Copy Markdown
Member

@luigidellaquila luigidellaquila commented Jun 19, 2024

So that registration is automatic.

Let's merge it after #109926 to make sure all the tests are good

private static final String FN_CBRT = "fn_cbrt";
public enum Cap {
// Support for function {@code CBRT}. Done in #108574.
FN_CBRT(false),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should these be lowercase since the beginning? Yeah, it's ugly, but it would be handy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer it the way you did it, with capitalized enum values, and lower case registration.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 on capitalized values.

I'd probably make a second ctor that defaults to false - it's just so so so much more common. Usually I wouldn't do that for things, but for this I think it's worth it.

for (NodeFeature feature : new EsqlFeatures().getHistoricalFeatures().keySet()) {
caps.add(cap(feature));
}
caps.add(STRING_LITERAL_AUTO_CASTING_TO_DATETIME_ADD_SUB);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I always wondered why this was registered after the others, as if it mattered somehow?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have no idea, but my feeling is that the order doesn't really matter

Copy link
Copy Markdown
Contributor

@craigtaverner craigtaverner left a comment

Choose a reason for hiding this comment

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

LGTM

private static final String FN_CBRT = "fn_cbrt";
public enum Cap {
// Support for function {@code CBRT}. Done in #108574.
FN_CBRT(false),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer it the way you did it, with capitalized enum values, and lower case registration.

Copy link
Copy Markdown
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.

Jinx!

Your version is even less verbose than mine, let's go with it!

*/
private static final String FN_CBRT = "fn_cbrt";
enum Cap {
// Support for function {@code CBRT}. Done in #108574.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's leave this as javadoc, so it shows up when hovering.

@luigidellaquila luigidellaquila marked this pull request as ready for review June 19, 2024 16:23
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 19, 2024
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

private static final String FN_CBRT = "fn_cbrt";
public enum Cap {
// Support for function {@code CBRT}. Done in #108574.
FN_CBRT(false),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 on capitalized values.

I'd probably make a second ctor that defaults to false - it's just so so so much more common. Usually I wouldn't do that for things, but for this I think it's worth it.

@luigidellaquila luigidellaquila added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jun 21, 2024
@elasticsearchmachine elasticsearchmachine merged commit 57f4870 into elastic:main Jun 21, 2024
@luigidellaquila luigidellaquila deleted the esql/safe_capabilities_registration branch June 21, 2024 08:22
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!) >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.15.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants