Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JSqlParser Features #1677

Unanswered
nitinp11 asked this question in Q&A
Nov 28, 2022 · 1 comments · 7 replies
Discussion options

Hi Team,

I am working on a task where I am reading more than 800 sqls and these sqls are having very long in nature and each sql is having keywords like case/when , Union , nested select , group by , where , with cte , joins etc.
Can this library parse bigger sql ? and after parsing can I get information like how many select statements are there and from that select how many select columns , how many tables from From clause , how many condition in AND/OR.
I need to get all such information.
I am new to this library , Can you kindly help to get this information? Is it possible and can i get this information?

Many Thanks

You must be logged in to vote

Replies: 1 comment 7 replies

Comment options

Greetings!

I am working on a task where I am reading more than 800 sqls and these sqls are having very long in nature and each sql is having keywords like case/when , Union , nested select , group by , where , with cte , joins etc. Can this library parse bigger sql ?

Yes.

and after parsing can I get information like how many select statements are there and from that select how many select columns , how many tables from From clause

Yes.

, how many condition in AND/OR

Yes.

. I need to get all such information. I am new to this library , Can you kindly help to get this information? Is it possible and can i get this information?

Yes.

Please refer to https://manticore-projects.com/JSQLParser/usage.html for details.

You must be logged in to vote
7 replies
Comment options

I suggest to use this link

It will visualize the Java Object Tree and the Hierarchy of classes ("Show AST" Button):

image

Comment options

Thanks for reply, will explore.

Comment options

This is perfectly giving the AST tree , but in order to get attributes of complex queries , do i need to write my own visitor or how to use existing ? Because i am trying to understand how it is generating a good tree and once it generates in order to traverse how to know how many selects/subselects/expressions are there.
I mean how to traverse to all the elements , is there any code sample available ?
Please reply.

Thanks

Comment options

Request you to please reply

Comment options

Greetings.

I have sent you a link showing code examples, how to traverse the AST and how to access the Objects.
I have also shown the visualisation for any AST, which will guide you.

You will need to ask much more specific questions, when you need help beyond that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /