Skip to content

Commit 1ad9d0b

Browse files
authored
SQL: Upgrade H2GIS library to 1.5.0 (#40461)
Upgrades H2GIS to 1.5.0, restores H2 version to 1.4.197 and removes work-around for bugs in H2 1.4.196 and jar conflicts in H2GIS 1.3.2.
1 parent ece7d92 commit 1ad9d0b

File tree

4 files changed

+18
-49
lines changed

4 files changed

+18
-49
lines changed

x-pack/plugin/sql/qa/build.gradle

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ dependencies {
1616

1717
// CLI testing dependencies
1818
compile project(path: xpackModule('sql:sql-cli'), configuration: 'nodeps')
19-
compile "org.orbisgis:h2gis-ext:1.3.2"
20-
19+
20+
// H2GIS testing dependencies
21+
compile ("org.orbisgis:h2gis:1.5.0") {
22+
exclude group: "org.locationtech.jts"
23+
}
24+
2125
// select just the parts of JLine that are needed
2226
compile("org.jline:jline-terminal-jna:${jlineVersion}") {
2327
exclude group: "net.java.dev.jna"
@@ -41,12 +45,8 @@ forbiddenApisMain {
4145
replaceSignatureFiles 'es-all-signatures', 'es-test-signatures'
4246
}
4347

44-
45-
thirdPartyAudit.ignoreMissingClasses (
46-
// TODO: Temporary solution until core removes JTS as a dependency
47-
'org.h2gis.functions.factory.H2GISFunctions',
48-
'org.h2gis.network.functions.NetworkFunctions',
49-
)
48+
// just a test fixture: we aren't using this jars in releases and H2GIS requires disabling a lot of checks
49+
thirdPartyAudit.enabled = false
5050

5151
subprojects {
5252
apply plugin: 'elasticsearch.standalone-rest-test'
@@ -63,8 +63,13 @@ subprojects {
6363

6464
// JDBC testing dependencies
6565
testRuntime "net.sourceforge.csvjdbc:csvjdbc:1.0.34"
66-
testRuntime "com.h2database:h2:1.4.196"
67-
testRuntime "org.orbisgis:h2gis-ext:1.3.2"
66+
testRuntime "com.h2database:h2:1.4.197"
67+
68+
// H2GIS testing dependencies
69+
testRuntime ("org.orbisgis:h2gis:1.5.0") {
70+
exclude group: "org.locationtech.jts"
71+
}
72+
6873
testRuntime project(path: xpackModule('sql:jdbc'), configuration: 'nodeps')
6974
testRuntime xpackProject('plugin:sql:sql-client')
7075

@@ -89,16 +94,6 @@ subprojects {
8994
testRuntime "org.elasticsearch:jna:${versions.jna}"
9095
}
9196

92-
// TODO: Temporary solution until core removes JTS as a dependency
93-
configurations {
94-
testRuntime {
95-
exclude group: 'org.locationtech.jts', module: 'jts-core'
96-
}
97-
testCompile {
98-
exclude group: 'org.locationtech.jts', module: 'jts-core'
99-
}
100-
}
101-
10297
if (project.name != 'security') {
10398
// The security project just configures its subprojects
10499
apply plugin: 'elasticsearch.rest-test'

x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/geo/GeoSqlSpecTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import org.elasticsearch.xpack.sql.qa.jdbc.LocalH2;
1111
import org.elasticsearch.xpack.sql.qa.jdbc.SpecBaseIntegrationTestCase;
1212
import org.elasticsearch.xpack.sql.jdbc.JdbcConfiguration;
13-
import org.h2gis.ext.H2GISExtension;
13+
import org.h2gis.functions.factory.H2GISFunctions;
1414
import org.junit.Before;
1515
import org.junit.ClassRule;
1616

@@ -32,7 +32,7 @@ public abstract class GeoSqlSpecTestCase extends SpecBaseIntegrationTestCase {
3232
@ClassRule
3333
public static LocalH2 H2 = new LocalH2((c) -> {
3434
// Load GIS extensions
35-
H2GISExtension.load(c);
35+
H2GISFunctions.load(c);
3636
c.createStatement().execute("RUNSCRIPT FROM 'classpath:/ogc/sqltsch.sql'");
3737
c.createStatement().execute("RUNSCRIPT FROM 'classpath:/geo/setup_test_geo.sql'");
3838
});

x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/JdbcAssert.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,7 @@ private static void doAssertResultSetData(ResultSet expected, ResultSet actual,
257257
}
258258
// then timestamp
259259
else if (type == Types.TIMESTAMP || type == Types.TIMESTAMP_WITH_TIMEZONE) {
260-
if (expected.getClass().getName().equals("org.h2.jdbc.JdbcResultSet")) {
261-
// TODO: This is a hack to work around no support for getTimestamp in H2 v1.4.196
262-
// I will remove it before merging when I can upgrade the branch to 1.4.197
263-
assertEquals(msg, expected.getTime(column, UTC_CALENDAR).getTime(),
264-
actual.getTime(column, UTC_CALENDAR).getTime());
265-
} else {
266-
assertEquals(msg, expected.getTimestamp(column), actual.getTimestamp(column));
267-
}
260+
assertEquals(msg, expected.getTimestamp(column), actual.getTimestamp(column));
268261
}
269262
// and floats/doubles
270263
else if (type == Types.DOUBLE) {

x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/LocalH2.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@
55
*/
66
package org.elasticsearch.xpack.sql.qa.jdbc;
77

8-
import org.apache.logging.log4j.LogManager;
9-
import org.apache.logging.log4j.Logger;
108
import org.elasticsearch.common.CheckedConsumer;
119
import org.elasticsearch.common.CheckedSupplier;
12-
import org.elasticsearch.common.SuppressForbidden;
1310
import org.junit.rules.ExternalResource;
1411

1512
import java.sql.Connection;
1613
import java.sql.DriverManager;
1714
import java.sql.SQLException;
18-
import java.util.Calendar;
19-
import java.util.Locale;
2015
import java.util.Properties;
2116

2217
public class LocalH2 extends ExternalResource implements CheckedSupplier<Connection, SQLException> {
23-
private final Logger logger = LogManager.getLogger(getClass());
2418

2519
/*
2620
* The syntax on the connection string is fairly particular:
@@ -60,7 +54,6 @@ public static Connection anonymousDb() throws SQLException {
6054
private final String url;
6155
// H2 in-memory will keep the db alive as long as this connection is opened
6256
private Connection keepAlive;
63-
Locale locale;
6457

6558
private CheckedConsumer<Connection, SQLException> initializer;
6659

@@ -70,14 +63,7 @@ public LocalH2(CheckedConsumer<Connection, SQLException> initializer) {
7063
}
7164

7265
@Override
73-
@SuppressForbidden(reason = "H2 gets really confused with non Gregorian calendars")
7466
protected void before() throws Throwable {
75-
if ("japanese".equals(Calendar.getInstance().getCalendarType())) {
76-
logger.info("Japanese calendar is detected. Overriding locale.");
77-
locale = Locale.getDefault();
78-
Locale.setDefault(locale.stripExtensions()); // removes the calendar setting
79-
assert "gregory".equals(Calendar.getInstance().getCalendarType());
80-
}
8167
keepAlive = get();
8268
initializer.accept(keepAlive);
8369
}
@@ -89,11 +75,6 @@ protected void after() {
8975
} catch (SQLException ex) {
9076
// close
9177
}
92-
if (locale != null) {
93-
logger.info("Restoring locale.");
94-
Locale.setDefault(locale);
95-
locale = null;
96-
}
9778
}
9879

9980
@Override

0 commit comments

Comments
 (0)