-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error reporting #108
Improve error reporting #108
Conversation
Map.Entry<Integer, FunctionSignature> bestMatchEntry = functionMatchQueue.peek(); | ||
if (FunctionSignature.NOT_MATCH.equals(bestMatchEntry.getKey())) { | ||
throw new ExpressionEvaluationException( | ||
String.format("%s function expected %s, but get %s", functionName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"%s function expected %s, but got %s"
Should probably be got not get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change copied from opensearch-project#746, it is not too late to post your proposals
} | ||
|
||
private String formatFunctions(Set<FunctionSignature> functionSignatures) { | ||
return functionSignatures.stream().map(FunctionSignature::formatTypes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this function, formatFunctions, do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It builds a list of function arguments in format like [STRING, STRING, INT]
f9757cf
to
ef19d06
Compare
// Check if all but the first parameter are of type STRING.
for (int i = 1; i < paramTypes.size(); i++) {
ExprType paramType = paramTypes.get(i);
if (!ExprCoreType.STRING.equals(paramType)) {
throw new SemanticCheckException(
getWrongParameterErrorMessage(i, paramType, ExprCoreType.STRING));
}
} |
5861f36
to
5182e6f
Compare
// Aggregate parameters by name, so getting a Map<Name:String, List> | ||
arguments.stream().collect(Collectors.groupingBy(a -> a.getArgName().toLowerCase())) | ||
.forEach((k, v) -> { | ||
if (v.size() > 1) { | ||
throw new SemanticCheckException( | ||
String.format("Parameter '%s' can only be specified once.", k)); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to aggregate all duplicates into one exception? Currently, function throws on first found duplicated parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we do other places...? I think we always throw on the first failure, but maybe you have an example where we aggregate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No examples. I don't think that we should worry about that, the probability that a user will specify multiple arguments more than once is extremely low I suppose. I just pointed that we have a room for further improvement.
...ava/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java
Outdated
Show resolved
Hide resolved
legacy/src/main/java/org/opensearch/sql/legacy/plugin/RestSqlAction.java
Outdated
Show resolved
Hide resolved
…t#806) Signed-off-by: penghuo <penghuo@gmail.com>
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please re-branch to remove commits from upstream. Are they in the integ-spik-improve-error-reporting branch? This is also tripping up the DCO check.
Also, is the first issue under issues left still valid? I thought the changes to FunctionResolver changed that error message.
Co-authored-by: MaxKsyunz <maxk@bitquilltech.com> Co-authored-by: forestmvey <forestv@bitquilltech.com> Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
98df515
to
1b0e047
Compare
20:46:03 /mnt/c/G/ope $ git pull --all
Fetching origin
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 31 (delta 19), reused 31 (delta 19), pack-reused 0
Unpacking objects: 100% (31/31), 4.75 KiB | 39.00 KiB/s, done.
From github.com:Bit-Quill/opensearch-project-sql
c751cc97..41df59e8 dev-Add-convert_tz-function -> origin/dev-Add-convert_tz-function
73ca29e8..65776edd dev-datetime-unix-convert -> origin/dev-datetime-unix-convert
Fetching upstream
remote: Enumerating objects: 20, done.
remote: Counting objects: 100% (11/11), done.
remote: Total 20 (delta 10), reused 10 (delta 10), pack-reused 9
Unpacking objects: 100% (20/20), 1.99 KiB | 23.00 KiB/s, done.
From github.com:opensearch-project/sql
53cde65a..b7b37da7 main -> upstream/main
Already up to date.
20:48:33 /mnt/c/G/ope $ git switch dev-spike-imrove-error-reporting
Already on 'dev-spike-imrove-error-reporting'
Your branch is up to date with 'origin/dev-spike-imrove-error-reporting'.
20:48:41 /mnt/c/G/ope $ git rebase upstream/main
First, rewinding head to replay your work on top of it...
Applying: Rework on error reporting to make it more verbose and human-friendly.
Applying: Improve check for `field` and `fields`.
Applying: Reorder V1 and V2 error messages.
20:49:01 /mnt/c/G/ope $ git push -f
Enumerating objects: 204, done.
Counting objects: 100% (204/204), done.
Delta compression using up to 4 threads
Compressing objects: 100% (96/96), done.
Writing objects: 100% (143/143), 20.22 KiB | 265.00 KiB/s, done.
Total 143 (delta 71), reused 12 (delta 3)
remote: Resolving deltas: 100% (71/71), completed with 37 local objects.
To github.com:Bit-Quill/opensearch-project-sql.git
+ 98df5156...1b0e0476 dev-spike-imrove-error-reporting -> dev-spike-imrove-error-reporting (forced update)
20:49:08 /mnt/c/G/ope $ git switch integ-spike-imrove-error-reporting
Switched to branch 'integ-spike-imrove-error-reporting'
Your branch is up to date with 'origin/integ-spike-imrove-error-reporting'.
20:49:25 /mnt/c/G/ope $ git rebase upstream/main
First, rewinding head to replay your work on top of it...
Fast-forwarded integ-spike-imrove-error-reporting to upstream/main.
20:49:32 /mnt/c/G/ope $ git push -f
Total 0 (delta 0), reused 0 (delta 0)
To github.com:Bit-Quill/opensearch-project-sql.git
53cde65a..b7b37da7 integ-spike-imrove-error-reporting -> integ-spike-imrove-error-reporting
20:49:36 /mnt/c/G/ope $ Now I have another commit shown in the list.
Thanks, updated. |
Can't avoid commits from upstream to be shown in my branches. I recreated branches and PR, see #116. |
Description
Note: contains changes from #88, it is not merged on upstream.
My changes are concentrated in
opensearch/src/main/java/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/*
and some changes on Forest's work inRestSQLQueryAction.java
,RestSqlAction.java
,QueryContext.java
andErrorMessage.java
+ changes on Max's PR inRelevanceQuery.java
.1.
Added cast validation and user-friendly error messages
before
after
2.
Cast validation and user-friendly errors for all enum types
before
after
3.
Extended error message when incorrect parameters specified
before
after
4.
A bit better error on typo in function name
before
after
Issues left
1.
These queries succeeds, but I expect a failure. It falls back to the old engine and devil knows how executed.
Proposal: disable this function in the old engine. Could be a breaking change...
2.
It is nice to have a enum with parameter names to avoid mistakes when adding new parameters/functions.
Code seems ugly, so I reverted this:
Not so relevant as far as we added almost all functions.
3.
I tried to add a mapping between functions, lists of their parameters and parameters' setters. The code was super-ugly...
Instead of having one line for each parameter for each function I got 4...
Ideas and proposals are welcome!
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.