Skip to content

[FEATURE] Add option to specify custom argument description/list #860

@Yury-Fridlyand

Description

@Yury-Fridlyand

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:

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

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions