Skip to content

Fix[2288] - Support parenthesed expressions within Between #2289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

davyboyhayes
Copy link
Contributor

@davyboyhayes davyboyhayes commented Aug 5, 2025

Fixes: #2288
Supports SQL of the form:

SELECT * FROM tbl WHERE
day BETWEEN
  CAST(CAST((NOW() + INTERVAL '-30 day') AS date) AS timestamptz)
AND
  CAST(CAST((NOW() + INTERVAL '-1 day') AS date) AS timestamptz);

Supports the SQL of the form:
```sql
SELECT * FROM tbl WHERE
day BETWEEN
  CAST(CAST((NOW() + INTERVAL '-30 day') AS date) AS timestamptz)
AND
  CAST(CAST((NOW() + INTERVAL '-1 day') AS date) AS timestamptz);
```
@manticore-projects
Copy link
Contributor

Can you please check with gradle jmh the performance impact?

@davyboyhayes
Copy link
Contributor Author

before each test:
gradle clean build

# JMH version: 1.37
# VM version: JDK 17.0.12, Java HotSpot(TM) 64-Bit Server VM, 17.0.12+8-LTS-286
# VM invoker: /Users/dhayes/.sdkman/candidates/java/17.0.12-oracle/bin/java

Before (JSQLParser:master):

Result "net.sf.jsqlparser.benchmark.JSQLParserBenchmark.parseSQLStatements":
  34.876 ±(99.9%) 3.130 ms/op [Average]
  (min, avg, max) = (31.860, 34.876, 39.507), stdev = 2.928
  CI (99.9%): [31.746, 38.006] (assumes normal distribution)

# Run complete. Total time: 00:03:49

After(davyboyhayes:fix/2288):

Result "net.sf.jsqlparser.benchmark.JSQLParserBenchmark.parseSQLStatements":
  36.546 ±(99.9%) 0.644 ms/op [Average]
  (min, avg, max) = (35.944, 36.546, 37.968), stdev = 0.602
  CI (99.9%): [35.902, 37.191] (assumes normal distribution)


# Run complete. Total time: 00:03:48

However, I suspect a longer run would produce more reliable performance results.

@davyboyhayes
Copy link
Contributor Author

With

jmh {
    includes = ['.*JSQLParserBenchmark.*']
    warmupIterations = 2
    fork = 5
    iterations = 5
    timeOnIteration = '5s'
}

(I have an M4 Max Macbook Pro)

Before:

Result "net.sf.jsqlparser.benchmark.JSQLParserBenchmark.parseSQLStatements":
  35.590 ±(99.9%) 1.599 ms/op [Average]
  (min, avg, max) = (31.337, 35.590, 37.378), stdev = 2.135
  CI (99.9%): [33.991, 37.189] (assumes normal distribution)


# Run complete. Total time: 00:11:20

After:

Result "net.sf.jsqlparser.benchmark.JSQLParserBenchmark.parseSQLStatements":
  35.344 ±(99.9%) 1.480 ms/op [Average]
  (min, avg, max) = (31.361, 35.344, 36.934), stdev = 1.975
  CI (99.9%): [33.864, 36.823] (assumes normal distribution)


# Run complete. Total time: 00:11:19

@manticore-projects manticore-projects merged commit f10b52e into JSQLParser:master Aug 5, 2025
2 of 3 checks passed
@manticore-projects
Copy link
Contributor

Thank you much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] JSQLParser Version : Postgres : BETWEEN with Cast
2 participants