You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem?
Current CASE functionality syntax is only available in SQL query, this functionality is important for actual use cases for Observability and in addition more general cases where eval CASE add helpful functionality to the query.
Examples:
The next example shows the case function evaluates the HTTP error codes stored in the error field:
Existing SQL syntax support has the following definition:
specificFunction
: CASE expression caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseFunctionCall
| CASE caseFuncAlternative+ (ELSE elseArg = functionArg)? END # caseFunctionCall
| CAST '(' expression AS convertedDataType ')' # dataTypeFunctionCall
;
caseFuncAlternative
: WHEN condition = functionArg THEN consequent = functionArg
;
We need the same support for PPL as shown in the above example.
Here is an example based on the existing SQL case syntax:
source = my_index
| eval status_category = CASE status_code
WHEN status_code >= 200 AND status_code < 300 THEN 'Success'
WHEN status_code >= 300 AND status_code < 400 THEN 'Redirection'
WHEN status_code >= 400 AND status_code < 500 THEN 'Client Error'
WHEN status_code >= 500 THEN 'Server Error'
ELSE 'Unknown'
END
| stats count() by status_category
What solution would you like?
We need support for PPL eval CASE functionality for both:
The CASE function is very useful whatever in SQL or PPL. I think we need it in PPL.
Simple is one of important design concepts of PPL, it would be redundant to completely copy the SQL syntax in PPL. Instead of adding the WHEN, THEN, ELSE and END keywords, I prefer to replace the branches with list of predicate-value pairs. My proposal of CASE function is:
ELSE could be optional, removing it will save an additional keyword in PPL. It is also more like a function than a clause.
The example in description could be change to
@LantaoJin thanks for your comments - I agree this is more pipeline oriented and looks in corespondent to other PPL commands @penghuo@dai-chen - LMK what you think ...
Is your feature request related to a problem?
Current
CASE
functionality syntax is only available in SQL query, this functionality is important for actual use cases for Observability and in addition more general cases where evalCASE
add helpful functionality to the query.Examples:
The next example shows the case function evaluates the HTTP error codes stored in the error field:
The next example shows the case function evaluates the
sort_field
wd
field type stored in the field:Existing SQL syntax support has the following definition:
We need the same support for PPL as shown in the above example.
Here is an example based on the existing SQL
case
syntax:What solution would you like?
We need support for PPL
eval CASE
functionality for both:- OpenSearch based PPL engine
- Spark based PPL engine
Do you have any additional context?
sql/sql/src/main/antlr/OpenSearchSQLParser.g4
Line 416 in 4303a2a
The text was updated successfully, but these errors were encountered: