Skip to content

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

Merged
RyanL1997 merged 2 commits into
opensearch-project:3.7from
RyanL1997:flint-validation-3.7
May 29, 2026
Merged

[Backport 3.7] Validate materialized view subqueries against SQL grammar deny list (#5485)#5489
RyanL1997 merged 2 commits into
opensearch-project:3.7from
RyanL1997:flint-validation-3.7

Conversation

@RyanL1997

@RyanL1997 RyanL1997 commented May 29, 2026

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

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit a3b1017)

Here are some key observations to aid the review process:

🧪 PR contains tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Null Pointer Risk

If SQLQueryUtils.extractIndexDetails(sqlQuery) returns null, calling indexQueryDetails.getMvQuery() will throw a NullPointerException. This can occur if the query format is unexpected or malformed, causing validation to fail with an unclear error instead of a meaningful validation message.

IndexQueryDetails indexQueryDetails = SQLQueryUtils.extractIndexDetails(sqlQuery);
String mvQuery = indexQueryDetails.getMvQuery();

@github-actions

github-actions Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Latest suggestions up to a3b1017
Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check for indexQueryDetails

Add null check for indexQueryDetails before accessing getMvQuery() to prevent
potential NullPointerException. The extractIndexDetails method might return null for
malformed or unexpected query formats, which would cause a runtime exception when
calling getMvQuery().

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: Adding a null check for indexQueryDetails before accessing getMvQuery() is a reasonable defensive programming practice that prevents potential NullPointerException. However, without knowing the implementation of SQLQueryUtils.extractIndexDetails(), we cannot confirm if it can return null. The suggestion addresses a potential runtime issue but may be unnecessary if the method guarantees non-null returns.

Medium

Previous suggestions

Suggestions up to commit 690c5a6
CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check for indexQueryDetails

Add null check for indexQueryDetails before accessing getMvQuery(). If
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: The suggestion correctly identifies a potential NullPointerException if extractIndexDetails returns null. However, without seeing the implementation of extractIndexDetails, we cannot confirm if this is a real issue. The suggestion is valid defensive programming practice, though it may be addressing a theoretical rather than actual problem.

Medium

Signed-off-by: Jialiang Liang <jiallian@amazon.com>
@RyanL1997 RyanL1997 added the enhancement New feature or request label May 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit a3b1017

@RyanL1997 RyanL1997 merged commit 0d2e7c3 into opensearch-project:3.7 May 29, 2026
41 of 42 checks passed
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