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

Support CASE clause in new engine #818

Conversation

dai-chen
Copy link
Member

@dai-chen dai-chen commented Nov 11, 2020

Issue #, if available: N/A

Description of changes: Add support for CASE clause in new SQL engine.

  1. Add AST and expression node for CASE and WHEN clause.
  2. Implement evaluation and type check. Because CASE clause is different from regular functions, it's not registered into function repository which usually performs the type check.

TODO: Case function for PPL is not done yet. Reference: https://docs.splunk.com/Documentation/Splunk/8.1.0/SearchReference/ConditionalFunctions

Documentation: https://github.com/dai-chen/sql/blob/support-case-statement-in-new-engine/docs/user/dql/functions.rst#case

Testing:

  1. Add UT.
  2. Add comparison test in https://github.com/dai-chen/sql/blob/support-case-statement-in-new-engine/integ-test/src/test/resources/correctness/expressions/conditionals.txt
  3. Ignore and fix broken legacy test cases.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dai-chen dai-chen added the SQL label Nov 11, 2020
@dai-chen dai-chen self-assigned this Nov 11, 2020
@dai-chen dai-chen marked this pull request as ready for review November 13, 2020 18:10
Copy link
Contributor

@penghuo penghuo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change!

@dai-chen dai-chen merged commit 2a98508 into opendistro-for-elasticsearch:develop Nov 16, 2020
@dai-chen dai-chen deleted the support-case-statement-in-new-engine branch November 16, 2020 21:21
penghuo pushed a commit that referenced this pull request Dec 15, 2020
* Change grammar and UT

* Add case expression

* Pass jacoco in sql module

* Pass jacoco in core module and refactor when clause

* Fix broken IT and add javadoc

* Add comparison test for basic case

* Add comparison test for complex case

* Add doctest

* Add type check

* Prepare PR

* Prepare PR

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

Successfully merging this pull request may close these issues.

3 participants