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

SQL: negative numbers surrounded by round brackets are not treated as negative #48009

Closed
astefan opened this issue Oct 14, 2019 · 2 comments · Fixed by #48113
Closed

SQL: negative numbers surrounded by round brackets are not treated as negative #48009

astefan opened this issue Oct 14, 2019 · 2 comments · Fixed by #48113
Assignees
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Oct 14, 2019

SELECT TRUNCATE(-1.5), TRUNCATE(-(1.5)), -(1.5)

TRUNCATE(-1.5) |TRUNCATE(-(1.5))|      1.5      
---------------+----------------+---------------
-1.0           |1.0             |1.5            

While the result should be obvious, in case it isn't -(1.5) seems to evaluate in the end to 1.5.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/SQL)

@matriv matriv self-assigned this Oct 15, 2019
matriv added a commit to matriv/elasticsearch that referenced this issue Oct 16, 2019
Previously when a numeric literal was enclosed in parentheses and then
negated, the negation was lost and the number was considered positive, e.g.:
`-(5)` was considered as `5` instead of `-5`
`- ( (1.28) )` was considered as `1.28` instead of `-1.28`

Fixes: elastic#48009
matriv added a commit that referenced this issue Oct 16, 2019
Previously when a numeric literal was enclosed in parentheses and then
negated, the negation was lost and the number was considered positive, e.g.:
`-(5)` was considered as `5` instead of `-5`
`- ( (1.28) )` was considered as `1.28` instead of `-1.28`

Fixes: #48009
matriv added a commit that referenced this issue Oct 16, 2019
Previously when a numeric literal was enclosed in parentheses and then
negated, the negation was lost and the number was considered positive, e.g.:
`-(5)` was considered as `5` instead of `-5`
`- ( (1.28) )` was considered as `1.28` instead of `-1.28`

Fixes: #48009

(cherry picked from commit 4dee4bf)
matriv added a commit that referenced this issue Oct 16, 2019
Previously when a numeric literal was enclosed in parentheses and then
negated, the negation was lost and the number was considered positive, e.g.:
`-(5)` was considered as `5` instead of `-5`
`- ( (1.28) )` was considered as `1.28` instead of `-1.28`

Fixes: #48009

(cherry picked from commit 4dee4bf)
matriv added a commit that referenced this issue Oct 16, 2019
Previously when a numeric literal was enclosed in parentheses and then
negated, the negation was lost and the number was considered positive, e.g.:
`-(5)` was considered as `5` instead of `-5`
`- ( (1.28) )` was considered as `1.28` instead of `-1.28`

Fixes: #48009

(cherry picked from commit 4dee4bf)
@matriv
Copy link
Contributor

matriv commented Oct 16, 2019

master : 4dee4bf
7.x : 3233bce
7.4 : e351678
6.8 : 74fe2f4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants