Skip to content
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 for New SQL Engine #88

Conversation

forestmvey
Copy link

Description

When a query fails both legacy and new SQL engines, only the legacy engine error is reported to the user. On failure in both the legacy and new SQL engines, error messages from both should be reported to the end user.

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

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.

Signed-off-by: forestmvey <forestv@bitquilltech.com>
Signed-off-by: forestmvey <forestv@bitquilltech.com>
private void reportError(final RestChannel channel, final Exception e, final RestStatus status, String newSqlEngineError) {
sendResponse(channel, ErrorMessageFactory.createErrorMessage(e, status.getStatus()).toString() + (newSqlEngineError.isEmpty()
? "" : "\nQuery failed both legacy and new SQL engines, see error message below for new SQL engine error.\n"
+ newSqlEngineError), status);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting a conditional within a concat is clunky. I would suggest saving the result of the conditional to a String variable would be cleaner.

* This member variable and it's usage can be deleted once the
* legacy SQL engine is deprecated.
*/
private String ErrorStr;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errorString - classes capitalize the first letter, not private variables.

@forestmvey
Copy link
Author

Failing tests will require updates with error outputs. Prior to me fixing all the tests and revising this PR could we confirm this error output format is appropriate:

new_sql_error_output

Signed-off-by: forestmvey <forestv@bitquilltech.com>
@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #88 (0467d13) into integ-sql_engine_error_improvements (58cfa88) will increase coverage by 0.02%.
The diff coverage is n/a.

@@                            Coverage Diff                            @@
##             integ-sql_engine_error_improvements      #88      +/-   ##
=========================================================================
+ Coverage                                  97.72%   97.74%   +0.02%     
- Complexity                                  2816     2859      +43     
=========================================================================
  Files                                        271      272       +1     
  Lines                                       6934     7006      +72     
  Branches                                     439      443       +4     
=========================================================================
+ Hits                                        6776     6848      +72     
  Misses                                       157      157              
  Partials                                       1        1              
Flag Coverage Δ
sql-engine 97.74% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <0.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <0.00%> (ø)
...h/sql/expression/function/OpenSearchFunctions.java 100.00% <0.00%> (ø)
...arch/storage/script/filter/FilterQueryBuilder.java 100.00% <0.00%> (ø)
...ript/filter/lucene/relevance/MatchPhraseQuery.java 100.00% <0.00%> (ø)
...ilter/lucene/relevance/MatchPhrasePrefixQuery.java 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58cfa88...0467d13. Read the comment docs.

…race separately in log to avoid logging un-anonymized data. Added function comments

Signed-off-by: forestmvey <forestv@bitquilltech.com>
@@ -109,6 +109,15 @@ Result set::
},
"status" : 400
}
Query failed on both V1 and V2 SQL parser engines. V2 SQL parser error following:
{
"error": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you whitespace is off here

@@ -39,7 +39,7 @@ public static String anonymizeData(String query) {
.replaceAll("[\\n][\\t]+", " ");
} catch (Exception e) {
LOG.warn("Caught an exception when anonymizing sensitive data");
resultQuery = query;
resultQuery = "Failed to anonymize data.";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should comment why we aren't returning the query any longer

@@ -39,7 +39,7 @@ public static String anonymizeData(String query) {
.replaceAll("[\\n][\\t]+", " ");
} catch (Exception e) {
LOG.warn("Caught an exception when anonymizing sensitive data");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a LOG.debug statement and output the failed query?

…ction

Signed-off-by: forestmvey <forestv@bitquilltech.com>
LOG.warn("Caught an exception when anonymizing sensitive data");
resultQuery = query;
LOG.warn("Caught an exception when anonymizing sensitive data.");
LOG.debug("String {} failed anonymization.", query);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still print the query on failure in the log.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in debug level which shouldn't be enabled in a production build right?

@forestmvey forestmvey merged commit ffe8995 into integ-sql_engine_error_improvements Jul 14, 2022
@forestmvey forestmvey deleted the dev-sql_engine_error_improvements branch July 14, 2022 17:04
@Yury-Fridlyand Yury-Fridlyand mentioned this pull request Aug 18, 2022
6 tasks
andy-k-improving pushed a commit that referenced this pull request Nov 16, 2024
* Apply lombok

Update compile task to recognize lombok
Use lombok wherever applicable
Use @nonnull notation
Use var for local variables

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants