GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor Parenthesed SelectBody and FromItem by manticore-projects · Pull Request #1754 · JSQLParser/JSqlParser

Conversation

@manticore-projects

@manticore-projects manticore-projects commented Mar 23, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This is a heavy API breaking refactoring on the bracket-handling related to SelectBody, FromItem and OperationSet, SubSelect, WithItem:

  • it fixes some issues and wrong examples (e. g. Test for Union with selects wrapped in parenthesis doesn't parse on 4.1 #1094, which was incorrect)
  • simplifies the Grammar and drops some redundant productions (e. g. SubSelect, SpecialSubSelect, SubJoin, SubJoinList, SetOperationListWithoutIntialSelect, ValuesList)

It should warrant a major Version JSQLParser-5.0 and also people should properly test it before.

Goal:

  • get rid of all the "hasBrackets" properties for any entity
  • move JoinList from PlainSelect to FromItem (since there can't be a Join without a From)
  • SelectBody replaces SubSelect and implements FromItem directly
    This has the big advantaged, that any occurrence of ( table=Table() | subSelect=SubSelect() ) can be parsed as fromItem=FromItem() without LOOKAHEAD (for example Merge parses a simple FromItem now)
  • SelectBody implements Statement directly and so becomes the Select Statement (removing 1 hierarchy level from the AST):
-- before
statement = new Select().withSelectBody(new PlainSelect()
                        .addSelectItems(new AllTableColumns().withTable(t)).withFromItem(t));
statement = new Select().withSelectBody(new ValuesStatement().withExpressions(expressionList));

-- now better ( when SelectBody became Select, all its implementations became a Statement )
statement = new PlainSelect()
                        .addSelectItems(new AllTableColumns().withTable(t)).withFromItem(t);
statement = new Values().withExpressions(expressionList);
  • LateralSubSelect extends ParenthesedSelectBody (axing SubSelect and SpecialSubSelect )

  • values.ValuesStatement becomes select.Values implementing SelectBody (with Statement and FromItem). So we got rid of ValuesList

  • move ORDER BY, LIMIT, OFFSET, FETCH, WITH isolation into SelectBody since all its implementations support it

    -- valid SQL
    values(1,2,3) limit 1
    -- valid SQL
    (values(1,2,3)) limit 1
  • Nested WithItems

    with a 
        as ( with b 
               as ( with c 
                      as (select 1) 
                      select c.* from c ) 
               select b.* from b ) 
         select a.* from a
  • Merge implements the Visitor Pattern

  • all the Tests succeed

  • verify/validate performance. It is a little bit slower but much more correct.

Before:
42500 statements parsed in 13095 milliseconds
 (3245 statements per second,  0.0003082 seconds per statement )
38500 select scans for table name executed in 80 milliseconds
 (481250 select scans for table name per second,  0.0000021 seconds per select scans for table name)

New:
42500 statements parsed in 15062 milliseconds
 (2821 statements per second,  0.0003545 seconds per statement )
38500 select scans for table name executed in 101 milliseconds
 (381188 select scans for table name per second,  0.0000026 seconds per select scans for table name)
  • so far 900 lines less code at better functionality and simplicity (traversing the AST got much easier)

Fixes #1737
Fixes #1764
Succeeds on another Special Oracle Test Condition15
Succeeds on another Special Oracle Test Cast_MultiSet07

@wumpz Please start reviewing and provide feedback as early as possible.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
zaza and others added 30 commits December 11, 2022 21:03
@zaza
Fixes JSQLParser#1684: Support CREATE MATERIALIZED VIEW with AUTO REF…
747152a
…RESH

Support parsing create view statements in Redshift with AUTO REFRESH
option.
@zaza
Merge branch 'master' into 1684-create-mv-auto-refresh
9e09005
@zaza
Reduce cyclomatic complexity in CreateView.toString
ea4477b
Extract adding the force option into a dedicated method resulting in the
cyclomatic complexity reduction of the CreateView.toString method.
@manticore-projects
Enhanced Keywords
b5321d6
Add Keywords and document, which keywords are allowed for what purpose
@manticore-projects
Fix incorrect tests
5fae2f5
@manticore-projects
Define Reserved Keywords explicitly
f49e828
Derive All Keywords from Grammar directly
Generate production for Object Names (semi-) automatically
Add parametrized Keyword Tests
@manticore-projects
Fix test resources
86f337d
@manticore-projects
Adjust Gradle to JUnit 5
2d51a82
Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10
@manticore-projects
Do not mark SpeedTest for concurrent execution
232aff6
@manticore-projects
Remove unused imports
3ba5410
@manticore-projects
Adjust Gradle to JUnit 5
e960a35
Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10
@manticore-projects
Do not mark SpeedTest for concurrent execution
67f7951
@manticore-projects
Remove unused imports
a016be0
@manticore-projects
Sphinx Documentation
2ef6637
Update the MANTICORE Sphinx Theme, but ignore it in GIT
Add the content to the Sphinx sites
Add a Gradle function to derive Stable and Snapshot version from GIT Tags
Add a Gradle GIT change task
Add a Gradle sphinx task
Add a special Test case for illustrating the use of JSQLParser
@manticore-projects
doc: request for Conventional Commit messages
57193b8
@manticore-projects
feat: make important Classes Serializable
b94b2cc
Implement Serializable for persisting via ObjectOutputStream
@manticore-projects
chore: Make Serializable
02202c5
@manticore-projects
doc: Better integration of the RR diagrams
a3ca325
- apply neutral Sphinx theme
- insert the RR diagrams into the sphinx sources
- better documentation on Gradle dependencies
- link GitHub repository
@manticore-projects
Merge
fcb5ab1
@manticore-projects
feat: Oracle Alternative Quoting
c57c427
- add support for Oracle Alternative Quoting e.g. `q'(...)'`
- fixes JSQLParser#1718
- add a Logo and FavIcon to the Website
- document recent changes on Quoting/Escaping
- add an example on building SQL from Java
- rework the README.md, promote the Website
- add Spotless Formatter, using Google Java Style (with Tab=4 Spaces)
@manticore-projects
style: Appease PMD/Codacy
2aec1f6
@manticore-projects
feat: CREATE VIEW ... REFRESH AUTO...
1c8d8da
- Merge PR JSQLParser#1691, fixes JSQLParser#1684
    all credits go to @zaza
@manticore-projects
doc: fix the issue template
b707b23
- fix the issue template
- fix the -SNAPSHOT version number
@manticore-projects
Update issue templates
46314c4
@manticore-projects
Update issue templates
4aeafbc
@manticore-projects
feat: Support more Statement Separators
b081484
- `GO`
- Slash `/`
- Two empty lines
@manticore-projects
Merge remote-tracking branch 'origin/master'
5885e1c
@manticore-projects
Merge branch 'master' of https://github.com/JSQLParser/JSqlParser
581d97a
@manticore-projects
feat: FETCH uses EXPRESSION
0979b2e
- `FETCH` uses `EXPRESSION` instead of SimpleJDBCParameter only
- Visit/Accept `FETCH` `EXPRESSION` instead of `append` to String
- Visit/Accept `OFFSET` `EXPRESSION` instead of `append` to String
- Gradle: remove obsolete/incompatible `jvmArgs` from Test()
@manticore-projects
style: apply Spotless
ed17f87
manticore-projects added 5 commits March 18, 2023 07:44
@manticore-projects
doc: fix reference in the Java Doc
f75df51
@manticore-projects
build: better Upload Groovy Task
500046f
@manticore-projects
feat: ParenthesedSelectBody and ParenthesedFromItem
e460cda
- First properly working version
- Work in progress, 13 tests failing
@manticore-projects
feat: ParenthesedSelectBody and ParenthesedFromItem
ad9e98d
- delete unneeded ParenthesedJoin
- rename ParenthesisFromItem into ParenthesedFromItem
@manticore-projects
Merge remote-tracking branch 'origin/master' into ParenthesedSelectBody
31935b3
@manticore-projects
manticore-projects marked this pull request as draft March 23, 2023 01:22
@manticore-projects manticore-projects self-assigned this Mar 23, 2023
@manticore-projects manticore-projects added the improvement label Mar 23, 2023
manticore-projects added 6 commits March 23, 2023 11:10
@manticore-projects
feat: ParenthesedSelectBody and ParenthesedFromItem
f0f8876
- fix `NULLS FIRST` and `NULLS LAST`
@manticore-projects
feat: ParenthesedSelectBody and ParenthesedFromItem
d134137
- fix Oracle Hints
@manticore-projects
feat: ParenthesedSelectBody and ParenthesedFromItem
616bf23
- parse `SetOperation` only after a (first plain) SelectBody has found, this fixes the performance issue
- one more special Oracle Test succeeds
- 5 remaining test failures
@manticore-projects
feat: ParenthesedSelectBody and ParenthesedFromItem
465934c
- extract `OrderByElements` into `SelectBody`
- one more special Oracle Test succeeds
- all tests succeed
@manticore-projects
style: Appease PMD/Codacy
9b3294c
@manticore-projects
style: Appease PMD/Codacy
e470d6e
@manticore-projects
manticore-projects marked this pull request as ready for review March 25, 2023 04:07
@manticore-projects
manticore-projects requested a review from wumpz March 25, 2023 04:07
@manticore-projects manticore-projects mentioned this pull request Mar 26, 2023
Add postgress nested with clause #361
Closed
manticore-projects added 7 commits March 26, 2023 19:05
@manticore-projects
feat: Refactor SelectBody implementations
9f999e3
- `SelectBody` implements `FromItem`
- get rid of `SubSelect` and `SpecialSubSelect`
- `Merge` can use `FromItem` instead of `SubSelect` or `Table`
- `LateralSubSelect` extends `ParenthesedSelectBody` directly
- Simplify the `Select` statement, although it is still redundant since     `SelectBody` also could implement `Statement` directly
- `WithItem` can use `SelectBody` directly, which allows for nested `WithItems`

BREAKING-CHANGE: Lots of redundant methods and intermediate removed
@manticore-projects
feat: Refactor SelectBody implementations
8cddd39
- `SelectBody` implements `Statement` and so makes `Select` redundant
- get rid of `ValuesList`
- refactor `ValuesStatement` into `Values` which just implements `SelectBody` (and becomes a `Statement` and a `FromItem`), move to `select` package

BREAKING-CHANGE: Lots of redundant methods and intermediate removed
@manticore-projects
style: Code cleanup
d0ea5e0
- remove 3 unused/obsolete productions
- appease PMD/Codacy
@manticore-projects
feat: Merge SelectBody into Select Statement
4056ca5
- former `SelectBody` implements `Statement` and so becomes `Select`
- this reduces the AST by 1 hierarchy level
@manticore-projects
style: Remove unused import
a6aab00
@manticore-projects
test: @disabled invalid Test
a914fe0
@manticore-projects
style: Appease PMD/Codacy
8b9dd3e
@manticore-projects

manticore-projects commented Apr 12, 2023

Copy link
Copy Markdown
Contributor Author

Can we move this forward please since it is quite a big chunk?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects manticore-projects mentioned this pull request Apr 14, 2023
How to convert Statement to Expression #1764
Closed
@manticore-projects
test: Add a SubSelect Parsing Test
ab127d4
@manticore-projects manticore-projects mentioned this pull request Apr 18, 2023
[BUG] JSQLParser 4.5/4.6 : RDBMS : extension field exception #1765
Closed
@wumpz
wumpz merged commit a312dcd into JSQLParser:master Apr 27, 2023
@manticore-projects
manticore-projects deleted the ParenthesedSelectBody branch April 29, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@wumpz wumpz Awaiting requested review from wumpz

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@manticore-projects manticore-projects

Labels

improvement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

How to convert Statement to Expression [BUG] JSQLParser Version 4.6 : MySQL : ParseException from using ORDER BY with UNION query

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@manticore-projects @wumpz @zaza
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.