Skip to content

Conversation

@aggarwalmayank
Copy link
Contributor

Description

[Describe what this change achieves]
adding capability in SQLQueryUtils to identify if SQL query is for creating a table or not.

Related Issues

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

NA

Check List

  • [ Y] New functionality includes testing.
  • [NA ] New functionality has been documented.
  • [ NA] New functionality has javadoc added.
  • [NA ] New functionality has a user manual doc added.
  • [NA ] API changes companion pull request created.
  • [ Y] Commits are signed per the DCO using --signoff.
  • [ NA] 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.

@aggarwalmayank aggarwalmayank changed the title adding capability to identify if SQL query is create table or not adding capability in SQLQueryUtils to identify if SQL query is for creating a table or not. Aug 13, 2025
@aggarwalmayank aggarwalmayank marked this pull request as ready for review August 13, 2025 07:15
Signed-off-by: Mayank Aggarwal <[email protected]>
@penghuo penghuo added the SQL label Aug 19, 2025
penghuo
penghuo previously approved these changes Aug 19, 2025
Copy link
Collaborator

@penghuo penghuo left a comment

Choose a reason for hiding this comment

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

@ykmr1224 Please take another look.

statement.accept(visitor);

// Remove duplicate table names
List<FullyQualifiedTableName> uniqueFullyQualifiedTableName = new LinkedList<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: let's put s at the end of the variable name (since it is a list)

new SqlBaseParser(
new CommonTokenStream(new SqlBaseLexer(new CaseInsensitiveCharStream(sqlQuery))));
sqlBaseParser.addErrorListener(new SyntaxAnalysisErrorListener());
return extractFullyQualifiedTableNamesWithMetadata(sqlQuery).getFullyQualifiedTableNames();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it actually avoid parsing query twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, users can use any of the method as per their requirement and the same visitor "SparkSqlTableNameVisitor" can be used

Signed-off-by: Mayank Aggarwal <[email protected]>
@penghuo penghuo added the enhancement New feature or request label Aug 20, 2025
@penghuo penghuo merged commit 5cb5181 into opensearch-project:main Aug 20, 2025
24 of 25 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 21, 2025
…eating a table or not. (#4029)

* adding capability to identify if SQL query is create table or not

Signed-off-by: Mayank Aggarwal <[email protected]>

* fixing codestyle violations

Signed-off-by: Mayank Aggarwal <[email protected]>

* updating variable name

Signed-off-by: Mayank Aggarwal <[email protected]>

---------

Signed-off-by: Mayank Aggarwal <[email protected]>
Co-authored-by: Mayank Aggarwal <[email protected]>
(cherry picked from commit 5cb5181)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.x
# Create a new branch
git switch --create backport/backport-4029-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 5cb51814ed1bb527c47a5e827c773a1899c081e9
# Push it to GitHub
git push --set-upstream origin backport/backport-4029-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-4029-to-2.x.

@ykmr1224
Copy link
Collaborator

Need manual backport.

Parasjg pushed a commit to Parasjg/sql that referenced this pull request Dec 24, 2025
…eating a table or not. (opensearch-project#4029)

* adding capability to identify if SQL query is create table or not

Signed-off-by: Mayank Aggarwal <[email protected]>

* fixing codestyle violations

Signed-off-by: Mayank Aggarwal <[email protected]>

* updating variable name

Signed-off-by: Mayank Aggarwal <[email protected]>

---------

Signed-off-by: Mayank Aggarwal <[email protected]>
Co-authored-by: Mayank Aggarwal <[email protected]>
@LantaoJin LantaoJin added the backport-manually Filed a PR to backport manually. label Dec 25, 2025
Parasjg pushed a commit to Parasjg/sql that referenced this pull request Dec 30, 2025
…eating a table or not. (opensearch-project#4029)

* adding capability to identify if SQL query is create table or not

Signed-off-by: Mayank Aggarwal <[email protected]>

* fixing codestyle violations

Signed-off-by: Mayank Aggarwal <[email protected]>

* updating variable name

Signed-off-by: Mayank Aggarwal <[email protected]>

---------

Signed-off-by: Mayank Aggarwal <[email protected]>
Co-authored-by: Mayank Aggarwal <[email protected]>
Signed-off-by: Paras jaggi <[email protected]>
LantaoJin pushed a commit that referenced this pull request Jan 7, 2026
…eating a table or not. (#4029) (#5007)

* adding capability to identify if SQL query is create table or not



* fixing codestyle violations



* updating variable name



---------

Signed-off-by: Mayank Aggarwal <[email protected]>
Signed-off-by: Paras jaggi <[email protected]>
Co-authored-by: Mayank Aggarwal <[email protected]>
Co-authored-by: Mayank Aggarwal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.x backport-failed backport-manually Filed a PR to backport manually. enhancement New feature or request SQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants