opensearch-project / opensearch-project/sql
[FEATURE] Add option to specify custom argument description/list
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 176
- Forks
- 229
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 43
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: https://github.com/opensearch-project/sql/blob/d81ef73c968b2ae7a9f52e362de294d4dec8e855/opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java#L622-L632
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 https://github.com/opensearch-project/sql/blob/e04d6f886aa57ee4fdd8e632127bb5d8a339113f/core/src/main/java/org/opensearch/sql/expression/function/DefaultFunctionResolver.java#L65-L68
What alternatives have you considered?
N/a
Do you have any additional context?
- Further improvement for changes done in #839
- Avoid overloaded error messages for some functions affected by #859
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with core/src/main/java/org/opensearch/sql/expression/function/DefaultFunctionResolver.java around the default error handling, then inspect FunctionResolver and the function registrations that supply argument signatures. Review the examples in opensearch/src/test/java/org/opensearch/sql/opensearch/storage/script/filter/FilterQueryBuilderTest.java. Done means supplied descriptions are used for relevant argument errors while existing defaults remain unchanged, with coverage for custom and fallback messages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100