-
Notifications
You must be signed in to change notification settings - Fork 139
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
Adds validation to allow only flint queries and sql SELECT queries to security lake type datasource #2959
Adds validation to allow only flint queries and sql SELECT queries to security lake type datasource #2959
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
88861bf
to
6302f62
Compare
logger.error( | ||
String.format( | ||
"Failed to parse sql statement context while validating sql query %s", sqlQuery), | ||
e); |
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.
Why do we add this error log?
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.
for better debuggability if there is a syntax error?
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.
As normal flow go through here, the log level should be info
or debug
.
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.
I am not sure if this is an info or debug level log
Imagine a bad sql query we are debugging in a log deep dive. It would be easier to trace it correctly if we throw error logs and user can also keep an eye on them.
this is an error
level log because we have caught an exception from a user input or from another system. I strongly feel this should be retained as error
level log
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.
I thought this skips SyntaxCheckException intentionally. @vamsi-amazon any thoughts?
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.
Yeah, I was little apprehensive to add error logs because..sometimes g4 files are not updated to the latest one from spark repo and this can result in syntax errors for valid queries. So, in case of syntax exceptions, I have decided to forward the query to spark in case of validation errors.
Now since we are clear on which spark version we are going to support, we should take g4 files from that branch and throw validation error in case of exception. what do you think @ykmr1224 ?
async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java
Outdated
Show resolved
Hide resolved
async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java
Show resolved
Hide resolved
async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java
Outdated
Show resolved
Hide resolved
async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java
Show resolved
Hide resolved
async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java
Show resolved
Hide resolved
async-query-core/src/test/java/org/opensearch/sql/spark/utils/SQLQueryUtilsTest.java
Outdated
Show resolved
Hide resolved
async-query-core/src/main/java/org/opensearch/sql/spark/utils/SQLQueryUtils.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/datasource/model/DataSourceType.java
Outdated
Show resolved
Hide resolved
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.
LGTM. If possible, can we add more types of queries in SQLQueryUtils test.
…asource Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
…y class Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
…ests Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
6b781d0
to
b8fc8c0
Compare
Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
… security lake type datasource (#2959) * allows only flint queries and select sql queries to security lake datasource Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * add sql validator for security lake and refactor validateSparkSqlQuery class Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * spotless fixes Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * address review comments. Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * address comment to extract validate logic into a separate method in tests Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * add more tests to get more code coverage Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> --------- Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> (cherry picked from commit 6c5c685) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
… security lake type datasource (#2959) * allows only flint queries and select sql queries to security lake datasource Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * add sql validator for security lake and refactor validateSparkSqlQuery class Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * spotless fixes Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * address review comments. Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * address comment to extract validate logic into a separate method in tests Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * add more tests to get more code coverage Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> --------- Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> (cherry picked from commit 6c5c685) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
… security lake type datasource (#2959) (#2977) * allows only flint queries and select sql queries to security lake datasource * add sql validator for security lake and refactor validateSparkSqlQuery class * spotless fixes * address review comments. * address comment to extract validate logic into a separate method in tests * add more tests to get more code coverage --------- (cherry picked from commit 6c5c685) Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
… security lake type datasource (#2959) (#2976) * allows only flint queries and select sql queries to security lake datasource * add sql validator for security lake and refactor validateSparkSqlQuery class * spotless fixes * address review comments. * address comment to extract validate logic into a separate method in tests * add more tests to get more code coverage --------- (cherry picked from commit 6c5c685) Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
Adds validation to allow only flint queries and sql select queries to security lake type datasource
Related Issues
Resolves #2907
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.