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: support CASE (WHEN) expression #36200

Closed
astefan opened this issue Dec 4, 2018 · 7 comments · Fixed by #41349
Closed

SQL: support CASE (WHEN) expression #36200

astefan opened this issue Dec 4, 2018 · 7 comments · Fixed by #41349

Comments

@astefan
Copy link
Contributor

astefan commented Dec 4, 2018

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql?view=sql-server-2017

Simples use case: SELECT (CASE WHEN (value = 1) THEN 'yes' ELSE 'no' END) AS decision FROM test

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@joaquinfernandez131
Copy link

Hello, in our use case it is vital to have the CASE (WHEN), is there an estimated date when this functionality would come into production?

@costin
Copy link
Member

costin commented Jan 29, 2019

Hi. This is on our roadmap and once we clarify the schedule we'll update the issue. Rest assured, we created the issue because we want to have this functionality addressed as we'll ship it as soon as possible. Once we have concrete dates, we'll update the ticket.
Thank you for your interest.

@matriv matriv self-assigned this Apr 3, 2019
matriv added a commit to matriv/elasticsearch that referenced this issue Apr 18, 2019
Implement the ANSI SQL CASE expression which provides the if/else
functionality common to most programming languages.

The CASE expression can have multiple WHEN branches and becomes a
powerful tool for SQL queries as it can be used in SELECT, WHERE,
GROUP BY, HAVING and ORDER BY clauses.

Closes: elastic#36200
matriv added a commit that referenced this issue Apr 22, 2019
Implement the ANSI SQL CASE expression which provides the if/else
functionality common to most programming languages.

The CASE expression can have multiple WHEN branches and becomes a
powerful tool for SQL queries as it can be used in SELECT, WHERE,
GROUP BY, HAVING and ORDER BY clauses.

Closes: #36200
matriv added a commit that referenced this issue Apr 22, 2019
Implement the ANSI SQL CASE expression which provides the if/else
functionality common to most programming languages.

The CASE expression can have multiple WHEN branches and becomes a
powerful tool for SQL queries as it can be used in SELECT, WHERE,
GROUP BY, HAVING and ORDER BY clauses.

Closes: #36200
(cherry picked from commit 8b25774)
@matriv
Copy link
Contributor

matriv commented Apr 22, 2019

Backported to 7.x with 67d4e39

gurkankaymak pushed a commit to gurkankaymak/elasticsearch that referenced this issue May 27, 2019
Implement the ANSI SQL CASE expression which provides the if/else
functionality common to most programming languages.

The CASE expression can have multiple WHEN branches and becomes a
powerful tool for SQL queries as it can be used in SELECT, WHERE,
GROUP BY, HAVING and ORDER BY clauses.

Closes: elastic#36200
@joey-91
Copy link

joey-91 commented Aug 15, 2019

Despite improvements I'm unable to make this query work,

SELECT
SUM(CASE WHEN "verb" = 'invite-phone' THEN 1 ELSE 0 END) as force
FROM "events-*"

Are there plans to add this functionality?

Thanks

@astefan
Copy link
Contributor Author

astefan commented Aug 16, 2019

@joey-91 that is a separate use case unfortunately, that comes with its own challenges. There is a github issue already created for that, for some time now: #37271

@rameshkr1994
Copy link

Hi new here for elastic search ;
need help 👍
https://discuss.elastic.co/t/how-can-we-convert-join-query-into-elastic-search/197783/2

please go through this link and help

Thanks

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

Successfully merging a pull request may close this issue.

8 participants