generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 181
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem?
A error returned to user in case if argument(s) are missing or have wrong type(s) is not user-friendly and usually confusing. As more signatures/arguments function has as less readable error become. See examples:
opensearchsql> SELECT PI(1);
{'reason': 'Invalid SQL query', 'details': 'pi function expected {[]}, but get [INTEGER]', 'type': 'ExpressionEvaluationException'}
opensearchsql> SELECT DATEDIFF();
{'reason': 'Invalid SQL query', 'details': 'datediff function expected {[DATE,DATE],[DATETIME,DATE],[DATE,DATETIME],[DATETIME,DATETIME],[DATE,TIME],[TIME,DATE],[TIME,TIME],[TIMESTAMP,DATE],[DATE,TIMESTAMP],[TIMESTAMP,TIMESTAMP],[TIMESTAMP,TIME],[TIME,TIMESTAMP],[TIMESTAMP,DATETIME],[DATETIME,TIMESTAMP],[TIME,DATETIME],[DATETIME,TIME]}, but get []', 'type': 'ExpressionEvaluationException'}
The goal is also to avoid such ugly messages like these:
Lines 622 to 632 in d81ef73
| assertEquals("simple_query_string function expected {[STRUCT,STRING],[STRUCT,STRING,STRING]," | |
| + "[STRUCT,STRING,STRING,STRING],[STRUCT,STRING,STRING,STRING,STRING],[STRUCT,STRING," | |
| + "STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING,STRING,STRING,STRING,STRING]," | |
| + "[STRUCT,STRING,STRING,STRING,STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING," | |
| + "STRING,STRING,STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING,STRING,STRING," | |
| + "STRING,STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING,STRING,STRING,STRING," | |
| + "STRING,STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING,STRING,STRING,STRING," | |
| + "STRING,STRING,STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING,STRING,STRING," | |
| + "STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING],[STRUCT,STRING,STRING," | |
| + "STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING,STRING]}," | |
| + " but get [STRUCT]", |
What solution would you like?
Add new field to FunctionResolver to store argument/function description. It should be returned (if given) instead of default message, see
sql/core/src/main/java/org/opensearch/sql/expression/function/DefaultFunctionResolver.java
Lines 65 to 68 in e04d6f8
| private String formatFunctions(Set<FunctionSignature> functionSignatures) { | |
| return functionSignatures.stream().map(FunctionSignature::formatTypes) | |
| .collect(Collectors.joining(",", "{", "}")); | |
| } |
What alternatives have you considered?
N/a
Do you have any additional context?
- Further improvement for changes done in Rework on error reporting to make it more verbose and human-friendly. #839
- Avoid overloaded error messages for some functions affected by [FEATURE] Add 3 interval types instead of 1 to support complex interval expressions #859
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request