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: NPE when using CASE WHEN with CASTed returned value #46551

Closed
astefan opened this issue Sep 10, 2019 · 2 comments · Fixed by #46565
Closed

SQL: NPE when using CASE WHEN with CASTed returned value #46551

astefan opened this issue Sep 10, 2019 · 2 comments · Fixed by #46565
Assignees
Labels

Comments

@astefan
Copy link
Contributor

astefan commented Sep 10, 2019

SELECT CASE WHEN salary IS NOT NULL THEN CAST(gender AS VARCHAR) ELSE gender END AS x FROM test_emp

[elasticsearch] java.lang.NullPointerException: null
[elasticsearch]         at org.elasticsearch.xpack.sql.plugin.TransportSqlQueryAction.createResponseWithSchema(TransportSqlQueryAction.java:100) ~[?:?]
[elasticsearch]         at org.elasticsearch.xpack.sql.plugin.TransportSqlQueryAction.lambda$operation$0(TransportSqlQueryAction.java:80) ~[?:?]
[elasticsearch]         at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.sql.execution.search.Querier$ScrollActionListener.lambda$handleResponse$2(Querier.java:432) [x-pack-sql-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.xpack.sql.execution.search.Querier$BaseActionListener.lambda$clear$3(Querier.java:530) [x-pack-sql-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.ActionListener$1.onResponse(ActionListener.java:63) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@matriv matriv self-assigned this Sep 10, 2019
matriv added a commit to matriv/elasticsearch that referenced this issue Sep 10, 2019
Many scalar functions try to find out the common type between their
arguments in order to set it as their return time, e.g.:
for <float> + <double> the common type which is set as the return type
of the + operation is double.

Previously, for data types TEXT and KEYWORD (string data types) there
was no common data type found and null was returned causing NPEs when
the function was trying to resolve the return data type.

Fixes: elastic#46551
matriv added a commit that referenced this issue Sep 11, 2019
Many scalar functions try to find out the common type between their
arguments in order to set it as their return time, e.g.:
for `float + double` the common type which is set as the return type
of the + operation is `double`.

Previously, for data types TEXT and KEYWORD (string data types) there
was no common data type found and null was returned causing NPEs when
the function was trying to resolve the return data type.

Fixes: #46551
matriv added a commit that referenced this issue Sep 11, 2019
Many scalar functions try to find out the common type between their
arguments in order to set it as their return time, e.g.:
for `float + double` the common type which is set as the return type
of the + operation is `double`.

Previously, for data types TEXT and KEYWORD (string data types) there
was no common data type found and null was returned causing NPEs when
the function was trying to resolve the return data type.

Fixes: #46551
(cherry picked from commit 291017d)
matriv added a commit that referenced this issue Sep 11, 2019
Many scalar functions try to find out the common type between their
arguments in order to set it as their return time, e.g.:
for `float + double` the common type which is set as the return type
of the + operation is `double`.

Previously, for data types TEXT and KEYWORD (string data types) there
was no common data type found and null was returned causing NPEs when
the function was trying to resolve the return data type.

Fixes: #46551
(cherry picked from commit 291017d)
matriv added a commit that referenced this issue Sep 11, 2019
Many scalar functions try to find out the common type between their
arguments in order to set it as their return time, e.g.:
for `float + double` the common type which is set as the return type
of the + operation is `double`.

Previously, for data types TEXT and KEYWORD (string data types) there
was no common data type found and null was returned causing NPEs when
the function was trying to resolve the return data type.

Fixes: #46551
(cherry picked from commit 291017d)
matriv added a commit that referenced this issue Sep 11, 2019
Many scalar functions try to find out the common type between their
arguments in order to set it as their return time, e.g.:
for `float + double` the common type which is set as the return type
of the + operation is `double`.

Previously, for data types TEXT and KEYWORD (string data types) there
was no common data type found and null was returned causing NPEs when
the function was trying to resolve the return data type.

Fixes: #46551
(cherry picked from commit 291017d)
@matriv
Copy link
Contributor

matriv commented Sep 11, 2019

master : 291017d
7.x : 0963e78
7.4 : 1e143f6
7.3 : 2afb7cf
6.8 : cb56550

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