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: "Should not fold expression" for conditional function #49387

Closed
astefan opened this issue Nov 20, 2019 · 2 comments · Fixed by #49449
Closed

SQL: "Should not fold expression" for conditional function #49387

astefan opened this issue Nov 20, 2019 · 2 comments · Fixed by #49449
Assignees
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Nov 20, 2019

SELECT IIF(20 = 0, NULL, salary / 20) FROM test_emp

results in

org.elasticsearch.xpack.sql.SqlIllegalArgumentException: Should not fold expression
        at org.elasticsearch.xpack.sql.expression.Expression.fold(Expression.java:72) ~[?:?]
        at org.elasticsearch.xpack.sql.expression.predicate.BinaryPredicate.fold(BinaryPredicate.java:32) ~[?:?]
        at org.elasticsearch.xpack.sql.expression.predicate.conditional.Case.fold(Case.java:132) ~[?:?]
        at org.elasticsearch.xpack.sql.expression.Literal.of(Literal.java:159) ~[?:?]
        at org.elasticsearch.xpack.sql.expression.Literal.of(Literal.java:144) ~[?:?]
        at org.elasticsearch.xpack.sql.optimizer.Optimizer$ConstantFolding.rule(Optimizer.java:1238) ~[?:?]
        at org.elasticsearch.xpack.sql.tree.Node.transformDown(Node.java:174) ~[?:?]
@elasticmachine
Copy link
Collaborator

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

@matriv matriv self-assigned this Nov 21, 2019
matriv added a commit to matriv/elasticsearch that referenced this issue Nov 21, 2019
Add extra checks to prevent ConstantFolding rule to try to fold
the CASE/IIF functions early before the SimplifyCase rule gets applied.

Fixes: elastic#49387
matriv added a commit that referenced this issue Nov 22, 2019
Add extra checks to prevent ConstantFolding rule to try to fold
the CASE/IIF functions early before the SimplifyCase rule gets applied.

Fixes: #49387
matriv added a commit that referenced this issue Nov 22, 2019
Add extra checks to prevent ConstantFolding rule to try to fold
the CASE/IIF functions early before the SimplifyCase rule gets applied.

Fixes: #49387

(cherry picked from commit f35c972)
@matriv
Copy link
Contributor

matriv commented Nov 22, 2019

master : f35c972
7.x : 0c44919
7.5 : 2508cc7
7.4 : 3dc6d58

matriv added a commit that referenced this issue Nov 22, 2019
Add extra checks to prevent ConstantFolding rule to try to fold
the CASE/IIF functions early before the SimplifyCase rule gets applied.

Fixes: #49387

(cherry picked from commit f35c972)
matriv added a commit that referenced this issue Nov 22, 2019
Add extra checks to prevent ConstantFolding rule to try to fold
the CASE/IIF functions early before the SimplifyCase rule gets applied.

Fixes: #49387

(cherry picked from commit f35c972)
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