Skip to content

Sqrt function for ESQL#98449

Merged
kkrik-es merged 6 commits intoelastic:feature/esqlfrom
kkrik-es:function/sqrt
Aug 16, 2023
Merged

Sqrt function for ESQL#98449
kkrik-es merged 6 commits intoelastic:feature/esqlfrom
kkrik-es:function/sqrt

Conversation

@kkrik-es
Copy link
Copy Markdown
Member

Introduces a unary scalar function for square root, which is a
thin wrapper over the Java.Math implementation.

Introduces a unary scalar function for square root, which is a thin
wrapper over the Java.Math implementation.
@github-actions
Copy link
Copy Markdown
Contributor

Documentation preview:

@kkrik-es kkrik-es self-assigned this Aug 14, 2023
@kkrik-es kkrik-es changed the base branch from main to feature/esql August 14, 2023 14:11
@nik9000
Copy link
Copy Markdown
Member

nik9000 commented Aug 15, 2023

@elasticsearchmachine update branch

@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine run elasticsearch-ci/part-3

@kkrik-es kkrik-es marked this pull request as ready for review August 16, 2023 05:08
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Aug 16, 2023
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

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

@kkrik-es kkrik-es added Team:QL (Deprecated) Meta label for query languages team and removed Team:QL (Deprecated) Meta label for query languages team labels Aug 16, 2023
@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine run elasticsearch-ci/docs-check

@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine run elasticsearch-ci/part-1

@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine create changelog

@kkrik-es
Copy link
Copy Markdown
Member Author

@elasticsearchmachine generate changelog

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

Apart from the missing unsigned long support, it LGTM.

return () -> new SqrtLongEvaluator(eval);
}

throw new UnsupportedOperationException("Unsupported type " + fieldType);
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.

The UNSIGNED_LONG support would need to be added too. OK if added in a subsequent PR.

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.

What's the suggested approach for handling it? Should it be handled as a long if less than Long. MAX_VALUE, otherwise as a double?

Since the rest of scalar functions don't handle it either, they can all be updated in a separate PR?

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.

I'd delay it, yeah. @bpintea maybe we need a meta issue to track missing functions for unsigned long. I imagine we have a few. And they are always kind of tricky to write.

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.

the rest of scalar functions don't handle it either

@kkrik-es which functions do you refer to? I was hoping I covered them all, but that might not be the case and I'll open an issue for those.

What's the suggested approach for handling it?

I think it'll eventually be fed to Math.sqrt() as a double, so converting to double should be fine imo.

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.

Right, that makes sense.

Wrt other functions, I see Log10 that I used as a template.

Copy link
Copy Markdown
Contributor

@bpintea bpintea Aug 16, 2023

Choose a reason for hiding this comment

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

@kkrik-es nice, yes, that's a bug.
I did a quick pass and I hope I didn't miss any other numeric function not supporting UL right now. EDIT: some aggs still need some support, so opened #98544.
If you want to have a look at both functions (i.e. this one and log10, which I think would be pretty similar) feel free to, otherwise I can have a look into log10 as well.

Copy link
Copy Markdown
Member Author

@kkrik-es kkrik-es Aug 17, 2023

Choose a reason for hiding this comment

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

I'm happy to take care of these two. I'll probably wait for merging to branch to main (if it hasn't happened) to avoid duplicate PRs.

@kkrik-es kkrik-es merged commit b498ce9 into elastic:feature/esql Aug 16, 2023
@kkrik-es kkrik-es deleted the function/sqrt branch August 16, 2023 14:07
@nik9000 nik9000 mentioned this pull request Aug 16, 2023
csoulios pushed a commit to csoulios/elasticsearch that referenced this pull request Aug 18, 2023
* Sqrt function for ESQL

Introduces a unary scalar function for square root, which is a thin
wrapper over the Java.Math implementation.

* Fix area for ESQL integration changelog.

* Restore changelog.

* Restore area in changelog.
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:QL (Deprecated) Meta label for query languages team v8.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants