Skip to content

[Backport 2.19] Validate materialized view subqueries against SQL grammar deny list (#5485)#5490

Open
RyanL1997 wants to merge 1 commit into
opensearch-project:2.19from
RyanL1997:flint-validation-2.19
Open

[Backport 2.19] Validate materialized view subqueries against SQL grammar deny list (#5485)#5490
RyanL1997 wants to merge 1 commit into
opensearch-project:2.19from
RyanL1997:flint-validation-2.19

Conversation

@RyanL1997
Copy link
Copy Markdown
Collaborator

Description

Validate materialized view subqueries against SQL grammar deny list

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

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.

…ar deny list (opensearch-project#5485)

Signed-off-by: Jialiang Liang <jiallian@amazon.com>
@github-actions
Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check for indexQueryDetails

Add null check for indexQueryDetails before accessing getMvQuery(). If
SQLQueryUtils.extractIndexDetails() returns null, calling getMvQuery() will throw a
NullPointerException. This could happen with malformed or unexpected query formats.

async-query-core/src/main/java/org/opensearch/sql/spark/validator/SQLQueryValidator.java [49-55]

 public void validateFlintExtensionQuery(String sqlQuery, DataSourceType dataSourceType) {
   IndexQueryDetails indexQueryDetails = SQLQueryUtils.extractIndexDetails(sqlQuery);
-  String mvQuery = indexQueryDetails.getMvQuery();
-  if (mvQuery != null) {
-    validate(mvQuery, dataSourceType);
+  if (indexQueryDetails != null) {
+    String mvQuery = indexQueryDetails.getMvQuery();
+    if (mvQuery != null) {
+      validate(mvQuery, dataSourceType);
+    }
   }
 }
Suggestion importance[1-10]: 7

__

Why: This is a valid defensive programming suggestion that prevents a potential NullPointerException if SQLQueryUtils.extractIndexDetails() returns null. While the suggestion addresses error handling, it's a moderate improvement since the actual behavior of extractIndexDetails() with malformed queries is unknown from the PR context.

Medium

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

Labels

enhancement New feature or request Security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants