Skip to content

Commit 0c31314

Browse files
committed
Merge origin/master
2 parents 0acb28f + af7bc1c commit 0c31314

File tree

7 files changed

+65
-3
lines changed

7 files changed

+65
-3
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ Also I would like to know about needed examples or documentation stuff.
5656

5757
## Extensions in the latest SNAPSHOT version 4.3
5858

59+
* moved to JUnit 5 as a test framework
60+
* added **IGNORE NULLS** to window functions
61+
5962
Additionally, we have fixed many errors and improved the code quality and the test coverage.
6063

6164
## Extensions of JSqlParser releases

build.gradle

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,13 @@ java.sourceCompatibility = JavaVersion.VERSION_1_8
1919
repositories {
2020
gradlePluginPortal()
2121
mavenLocal()
22+
mavenCentral()
2223
maven {
2324
url = uri('https://repo.maven.apache.org/maven2/')
2425
}
26+
maven {
27+
url "https://plugins.gradle.org/m2/"
28+
}
2529
}
2630

2731
dependencies {
@@ -36,6 +40,12 @@ dependencies {
3640
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.1'
3741
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
3842

43+
// https://mvnrepository.com/artifact/org.mockito/mockito-junit-jupiter
44+
testImplementation 'org.mockito:mockito-junit-jupiter:4.1.0'
45+
46+
// enforce latest version of JavaCC
47+
javacc 'net.java.dev.javacc:javacc:7.0.10'
48+
3949
}
4050

4151
compileJavacc {
@@ -56,6 +66,18 @@ jacoco {
5666
}
5767

5868
test {
69+
useJUnitPlatform()
70+
71+
// set heap size for the test JVM(s)
72+
minHeapSize = "128m"
73+
maxHeapSize = "1G"
74+
75+
jvmArgs << [
76+
'-Djunit.jupiter.execution.parallel.enabled=true',
77+
'-Djunit.jupiter.execution.parallel.config.strategy=dynamic',
78+
'-Djunit.jupiter.execution.parallel.mode.default=concurrent'
79+
]
80+
5981
finalizedBy jacocoTestReport // report is always generated after tests run
6082
finalizedBy jacocoTestCoverageVerification
6183
}
@@ -93,7 +115,7 @@ jacocoTestCoverageVerification {
93115
limit {
94116
counter = 'LINE'
95117
value = 'MISSEDCOUNT'
96-
maximum = 5458
118+
maximum = 5500
97119
}
98120
excludes = [
99121
'net.sf.jsqlparser.util.validation.*',

gradle.properties

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Specifies the JVM arguments used for the daemon process.
2+
# The setting is particularly useful for tweaking memory settings.
3+
org.gradle.jvmargs=-Xmx1G -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError
4+
5+
org.gradle.caching=true
6+
7+
# Modularise your project and enable parallel build
8+
org.gradle.parallel=true
9+
10+
# Enable configure on demand.
11+
org.gradle.configureondemand=true
12+

src/main/java/net/sf/jsqlparser/expression/AnalyticExpression.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public class AnalyticExpression extends ASTNodeAccessImpl implements Expression
3636
private AnalyticType type = AnalyticType.OVER;
3737
private boolean distinct = false;
3838
private boolean unique = false;
39-
private boolean ignoreNulls = false;
39+
private boolean ignoreNulls = false; //IGNORE NULLS inside function parameters
40+
private boolean ignoreNullsOutside = false; //IGNORE NULLS outside function parameters
4041
private Expression filterExpression = null;
4142
private WindowElement windowElement = null;
4243
private List<OrderByElement> funcOrderBy = null;
@@ -178,6 +179,14 @@ public void setIgnoreNulls(boolean ignoreNulls) {
178179
this.ignoreNulls = ignoreNulls;
179180
}
180181

182+
public boolean isIgnoreNullsOutside() {
183+
return ignoreNullsOutside;
184+
}
185+
186+
public void setIgnoreNullsOutside(boolean ignoreNullsOutside) {
187+
this.ignoreNullsOutside = ignoreNullsOutside;
188+
}
189+
181190
@Override
182191
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity", "PMD.MissingBreakInSwitch"})
183192
public String toString() {
@@ -220,6 +229,10 @@ public String toString() {
220229
}
221230
}
222231

232+
if (isIgnoreNullsOutside()) {
233+
b.append("IGNORE NULLS ");
234+
}
235+
223236
switch (type) {
224237
case FILTER_ONLY:
225238
return b.toString();

src/main/java/net/sf/jsqlparser/util/deparser/ExpressionDeParser.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,10 @@ public void visit(AnalyticExpression aexpr) {
674674
buffer.append(" ");
675675
}
676676
}
677+
678+
if (aexpr.isIgnoreNullsOutside()) {
679+
buffer.append("IGNORE NULLS ");
680+
}
677681

678682
switch (aexpr.getType()) {
679683
case FILTER_ONLY:

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4184,7 +4184,7 @@ void windowFun(AnalyticExpression retval):{
41844184
WindowElement windowElement = null;
41854185
boolean partitionByBrackets = false;
41864186
} {
4187-
(<K_OVER> {retval.setType(AnalyticType.OVER);}
4187+
([<K_IGNORE> <K_NULLS> { retval.setIgnoreNullsOutside(true); } ] <K_OVER> {retval.setType(AnalyticType.OVER);}
41884188
| <K_WITHIN> <K_GROUP> {retval.setType(AnalyticType.WITHIN_GROUP);} )
41894189

41904190
"("

src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
import static org.junit.jupiter.api.Assertions.fail;
4646
import org.junit.jupiter.api.Disabled;
4747
import org.junit.jupiter.api.Test;
48+
import org.junit.jupiter.api.parallel.Execution;
49+
import org.junit.jupiter.api.parallel.ExecutionMode;
4850

51+
@Execution(ExecutionMode.CONCURRENT)
4952
public class SelectTest {
5053

5154
private final CCJSqlParserManager parserManager = new CCJSqlParserManager();
@@ -4972,4 +4975,9 @@ public void testLogicalExpressionSelectItemIssue1381() throws JSQLParserExceptio
49724975
public void testKeywordAtIssue1414() throws JSQLParserException {
49734976
assertSqlCanBeParsedAndDeparsed("SELECT * FROM table1 at");
49744977
}
4978+
4979+
@Test
4980+
public void testIgnoreNullsForWindowFunctionsIssue1429() throws JSQLParserException {
4981+
assertSqlCanBeParsedAndDeparsed("SELECT lag(mydata) IGNORE NULLS OVER (ORDER BY sortorder) AS previous_status FROM mytable");
4982+
}
49754983
}

0 commit comments

Comments
 (0)