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] Improve arithmetic unary expression nodes #189258

Open
Tracked by #194385
vadimkibana opened this issue Jul 26, 2024 · 1 comment · May be fixed by #196817
Open
Tracked by #194385

[ES|QL] Improve arithmetic unary expression nodes #189258

vadimkibana opened this issue Jul 26, 2024 · 1 comment · May be fixed by #196817
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana

Comments

@vadimkibana
Copy link
Contributor

For unary arithmetic expressions, say -column, the constructed AST is modified to create a binary expression where column is multiplied by -1. So, -column is transformed to -1 * column. Instead we should just create a unary expression function call node. We are already doing that for NOT unary expressions, like NOT column.

@vadimkibana vadimkibana added Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana labels Jul 26, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@vadimkibana vadimkibana added the bug Fixes for quality problems that affect the customer experience label Oct 17, 2024
@vadimkibana vadimkibana self-assigned this Oct 17, 2024
vadimkibana added a commit that referenced this issue Oct 22, 2024
## Summary

Partially addresses #189258

This change will likely supercede
#196817

When parsing, currently ES|QL parsers adds extraneous multiply by 1 or
multiply by -1 nodes when parsing arithmetic unary expressions.

For example, `-(x)` is parsed as `-1 * x`.

This change, reverts these when pretty-printing using the
`BasicPrettyPrinter`: `-1 * x` is pretty printed as `-x`.


### Checklist

Delete any items that are not applicable to this PR.

- [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


### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 22, 2024
…#197182)

## Summary

Partially addresses elastic#189258

This change will likely supercede
elastic#196817

When parsing, currently ES|QL parsers adds extraneous multiply by 1 or
multiply by -1 nodes when parsing arithmetic unary expressions.

For example, `-(x)` is parsed as `-1 * x`.

This change, reverts these when pretty-printing using the
`BasicPrettyPrinter`: `-1 * x` is pretty printed as `-x`.

### Checklist

Delete any items that are not applicable to this PR.

- [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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)

(cherry picked from commit 848c9f4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants