CASE WHEN THEN

I have put this Query on Canva Elasticsearch SQL query :
SELECT CASE sexe
WHEN 1 THEN 'Male'
WHEN 2 THEN 'Female'
END
FROM "test*"
WHERE sexe IS NOT NULL

I have this error message :
Whoops! Expression failed

Expression failed with the message:

[essql] > Couldn't parse Elasticsearch SQL query. You may need to add double quotes to names containing special characters. Check your query and try again. Error: [parsing_exception] line 2:1: mismatched input 'WHEN' expecting {, ',', 'FROM', 'GROUP', 'HAVING', 'LIMIT', 'ORDER', 'WHERE', '{LIMIT'}

@Farouk6072 what Elasticsearch version is this?

v6.6.1 cloud version

CASE WHEN has been added in 7.2.0 and the error you get is the expected one. That feature is simply not available in 6.x. https://github.com/elastic/elasticsearch/issues/36200

1 Like

Thank you very much

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.