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

Fix sql syntax error user #16583

Merged
merged 4 commits into from
Jun 11, 2024
Merged

Conversation

zachjsh
Copy link
Contributor

@zachjsh zachjsh commented Jun 10, 2024

Description

This fixes an issue where in some cases, a SqlParseException encountered when parsing a query results in an error returned to the user with persona a DEVELOPER when it should instead be USER.

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@@ -380,13 +380,7 @@ public static DruidException translateException(Exception e)
}
}

return DruidException.forPersona(DruidException.Persona.DEVELOPER)
Copy link
Contributor

@abhishekrb19 abhishekrb19 Jun 10, 2024

Choose a reason for hiding this comment

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

This makes sense to me since this is still a case of SqlParseException.

@zachjsh, do you mind adding a test with a bad SQL that would cause the exception to be targeted towards a user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Comment on lines 688 to 689
// For this reason, we consider these as targetting a more expert persona, i.e. the admin instead of the actual
// user.
Copy link
Member

Choose a reason for hiding this comment

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

The removed comment provides the reason why it was not target to the USER ; I think we should leave the uncategorized ones to ADMIN or something

if there is a particular set of exceptions which should be hardened; maybe those should be targeted directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted this part of the change, thanks for taking a look!

@zachjsh zachjsh merged commit 3f5f592 into apache:master Jun 11, 2024
29 checks passed
@zachjsh zachjsh deleted the fix-sql-syntax-error-user branch June 11, 2024 22:08
"Unable to parse the SQL, unrecognized error from calcite: [%s]",
inner.getMessage()
);
return InvalidSqlInput.exception(inner.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

this exception creation clips the stacktrace - it only retains the source exceptions message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants