Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

case statement is not working properly #582

Closed
dheerajravindranath opened this issue Jul 17, 2020 · 3 comments
Closed

case statement is not working properly #582

dheerajravindranath opened this issue Jul 17, 2020 · 3 comments
Labels

Comments

@dheerajravindranath
Copy link

dheerajravindranath commented Jul 17, 2020

Elasticsearch Verison: 7.4

{
"query": "select distinct(case when event='test' then user_id end) as testing from events_testing where event='test' and team_id=xxxxx"
}

{
"error": {
"reason": "Invalid SQL query",
"details": "",
"type": "NullPointerException"
},
"status": 400
}

The same query is working fine in other DB. Could someone help me to resolve this?

@dai-chen
Copy link
Member

@dheerajravindranath Thanks for reporting the issue! I think we only support simple DISTINCT(* ) and DISTINCT(field). Will let you know if we can fix this or workaround found for your case.

@dai-chen dai-chen added the SQL label Jul 20, 2020
@dheerajravindranath
Copy link
Author

Thanks, @dai-chen It would be great if we get this resolved asap!

@dai-chen
Copy link
Member

This issue has been resolved in our new SQL engine. Please find more details here: https://github.com/opendistro-for-elasticsearch/sql#experimental.

Test queries verified in PR above: https://github.com/opendistro-for-elasticsearch/sql/blob/develop/integ-test/src/test/resources/correctness/bugfixes/582.txt

SELECT DISTINCT CASE WHEN Carrier = 'ES-Air' Then FlightDelayMin END AS delay FROM kibana_sample_data_flights
SELECT DISTINCT CASE WHEN FlightDelay = true Then Carrier END AS name FROM kibana_sample_data_flights
SELECT DISTINCT CASE WHEN FlightDelay = true Then Carrier WHEN FlightDelay = false THEN NULL END AS name FROM kibana_sample_data_flights

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

No branches or pull requests

2 participants