Skip to content

Commit

Permalink
[CALCITE-6587] Support Java 23 and Guava 33.3.0; upgrade Hadoop from …
Browse files Browse the repository at this point in the history
…2.7.5 to 2.10.2

Revise UtilTest.testPosixTimeZone() becauase format of time
zones have changed in JDK 23.

Disable some tests due to this bug:
 * Disable CalciteRemoteDriverTest,
   RemotePreparedStatementParametersTest on JDK 23 until
   [CALCITE-6588] is fixed in Avatica; we plan to fix in
   Avatica 1.26;
 * Disable Pig and Spark tests on JDK 23 until
   [HADOOP-19212] is fixed.

In GitHub workflow (CI):
 * Test against JDK 23 (replacing previous JDK 22 test);
 * Refactor so that oldest, latest and default Guava versions
   are defined in one place;
 * Clean up descriptions of CI jobs.

Add `class Version`, to make it easier to parse and compare
version strings.

Close #3971
  • Loading branch information
julianhyde committed Sep 20, 2024
1 parent 98b252b commit e314fcc
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 70 deletions.
46 changes: 19 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ concurrency:
env:
_JAVA_OPTIONS: '-XX:GCTimeLimit=90 -XX:GCHeapFreeLimit=35'
DEVELOCITY_ACCESS_KEY: ${{ secrets.GE_ACCESS_TOKEN }}
GUAVA_MIN: '21.0' # oldest supported Guava version
GUAVA_MAX: '33.3.0-jre' # latest supported Guava version
GUAVA: '21.0' # most jobs test against oldest Guava version

jobs:
windows-jdk8:
Expand Down Expand Up @@ -140,11 +143,10 @@ jobs:
linux-jdk8-oldest-guava-tz:
if: github.event.action != 'labeled'
name: 'Linux (JDK 8), oldest Guava, America/New_York Timezone'
name: 'Linux (JDK 8, oldest Guava, America/New_York Timezone)'
runs-on: ubuntu-latest
env:
TZ: 'America/New_York' # flips between −05:00 and −04:00
GUAVA: '21.0' # oldest Guava
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -159,15 +161,14 @@ jobs:
with:
job-id: jdk${{ matrix.jdk }}
remote-build-cache-proxy-enabled: false
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} build
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MIN }} build

linux-jdk8-latest-guava-tz:
if: github.event.action != 'labeled'
name: 'Linux (JDK 8), latest Guava, America/New_York Timezone'
name: 'Linux (JDK 8, latest Guava, America/New_York Timezone)'
runs-on: ubuntu-latest
env:
TZ: 'America/New_York' # flips between −05:00 and −04:00
GUAVA: '32.1.3-jre' # latest supported Guava version
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -182,11 +183,11 @@ jobs:
with:
job-id: jdk${{ matrix.jdk }}
remote-build-cache-proxy-enabled: false
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} tasks build
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MAX }} tasks build

linux-jdk11-tz:
if: github.event.action != 'labeled'
name: 'Linux (JDK 11), Pacific/Chatham Timezone'
name: 'Linux (JDK 11, Pacific/Chatham Timezone)'
runs-on: ubuntu-latest
env:
TZ: 'Pacific/Chatham' # flips between +12:45 and +13:45
Expand All @@ -210,8 +211,6 @@ jobs:
if: github.event.action != 'labeled'
name: 'Linux (JDK 17)'
runs-on: ubuntu-latest
env:
GUAVA: '21.0' # oldest Guava
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -232,8 +231,6 @@ jobs:
if: github.event.action != 'labeled'
name: 'Linux (JDK 21)'
runs-on: ubuntu-latest
env:
GUAVA: '21.0' # oldest Guava
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -250,20 +247,18 @@ jobs:
remote-build-cache-proxy-enabled: false
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} build

linux-jdk22: # latest JDK version supported by ForbiddenAPIs plugin, keep this updated (see https://jdk.java.net/)
linux-jdk23: # latest JDK version supported by ForbiddenAPIs plugin, keep this updated (see https://jdk.java.net/)
if: github.event.action != 'labeled'
name: 'Linux (JDK 22)'
name: 'Linux (JDK 23)'
runs-on: ubuntu-latest
env:
GUAVA: '21.0' # oldest Guava
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 50
- name: 'Set up JDK 22'
- name: 'Set up JDK 23'
uses: actions/setup-java@v2
with:
java-version: 22
java-version: 23
distribution: 'zulu'
- uses: burrunan/gradle-cache-action@v1
name: Test
Expand All @@ -274,7 +269,7 @@ jobs:

linux-avatica:
if: github.event.action != 'labeled'
name: 'Linux (JDK 11), Avatica main'
name: 'Linux (JDK 11, Avatica main)'
runs-on: ubuntu-latest
steps:
- name: 'Set up JDK 11'
Expand Down Expand Up @@ -338,12 +333,10 @@ jobs:
echo sqlsh
./sqlsh -o headers "select count(*) commits, author from (select substring(author, 1, position(' <' in author)-1) author from git_commits) group by author order by count(*) desc, author limit 20"
errorprone-guava-latest: # LTS JDK version, don't remove until EOL
errorprone-guava-latest:
if: github.event.action != 'labeled'
name: 'Error Prone (JDK 11), latest Guava'
name: 'ErrorProne (JDK 11, latest Guava)'
runs-on: ubuntu-latest
env:
GUAVA: '32.1.3-jre' # ErrorProne checks for Beta APIs, so use the latest supported Guava version
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -358,7 +351,8 @@ jobs:
with:
job-id: errprone
remote-build-cache-proxy-enabled: false
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} -PenableErrorprone classes
# ErrorProne checks for Beta APIs, so use the latest supported Guava version
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MAX }} -PenableErrorprone classes

linux-checkerframework:
name: 'CheckerFramework (JDK 11)'
Expand All @@ -380,10 +374,8 @@ jobs:
arguments: --scan --no-parallel --no-daemon -PenableCheckerframework :linq4j:classes :core:classes :server:classes

linux-checkerframework-oldest-guava:
name: 'CheckerFramework (JDK 11), oldest Guava'
name: 'CheckerFramework (JDK 11, oldest Guava)'
runs-on: ubuntu-latest
env:
GUAVA: '21.0' # oldest Guava
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -398,7 +390,7 @@ jobs:
with:
job-id: checkerframework-jdk11
remote-build-cache-proxy-enabled: false
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA }} -PenableCheckerframework :linq4j:classes :core:classes :server:classes
arguments: --scan --no-parallel --no-daemon -Pguava.version=${{ env.GUAVA_MIN }} -PenableCheckerframework :linq4j:classes :core:classes :server:classes

linux-slow:
# Run slow tests when the commit is on main or it is requested explicitly by adding an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.calcite.test.schemata.hr.Employee;
import org.apache.calcite.util.TestUtil;
import org.apache.calcite.util.Util;
import org.apache.calcite.util.Version;

import com.google.common.collect.ImmutableList;

Expand Down Expand Up @@ -82,6 +83,7 @@
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

import static java.util.Objects.requireNonNull;

Expand All @@ -106,6 +108,11 @@ class CalciteRemoteDriverTest {
private static @Nullable HttpServer start;

@BeforeAll public static void beforeClass() throws Exception {
assumeFalse(TestUtil.getJavaMajorVersion() >= 23
&& TestUtil.AVATICA_VERSION.compareTo(Version.of(1, 25)) > 0,
"Cannot run on JDK 23 and higher with Avatica version 1.25 or lower; "
+ "enable when [CALCITE-6588] is fixed in Avatica");

localConnection = CalciteAssert.hr().connect();

// Make sure we pick an ephemeral port for the server
Expand Down
67 changes: 31 additions & 36 deletions core/src/test/java/org/apache/calcite/util/UtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import static org.apache.calcite.util.ReflectUtil.isStatic;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -643,30 +644,28 @@ private List<Integer> makeConsList(int start, int end) {
* Tests the {@link Util#toPosix(TimeZone, boolean)} method.
*/
@Test void testPosixTimeZone() {
// NOTE jvs 31-July-2007: First two tests are disabled since
// not everyone may have patched their system yet for recent
// DST change.

// Pacific Standard Time. Effective 2007, the local time changes from
// PST to PDT at 02:00 LST to 03:00 LDT on the second Sunday in March
// and returns at 02:00 LDT to 01:00 LST on the first Sunday in
// November.
if (false) {
assertEquals(
"PST-8PDT,M3.2.0,M11.1.0",
Util.toPosix(TimeZone.getTimeZone("PST"), false));
assertThat(Util.toPosix(TimeZone.getTimeZone("PST"), false),
anyOf(is("PST-8PDT,M3.2.0,M11.1.0"),
is("GMT-08:00-8GMT-07:00,M3.2.0,M11.1.0")));

assertEquals(
"PST-8PDT1,M3.2.0/2,M11.1.0/2",
Util.toPosix(TimeZone.getTimeZone("PST"), true));
}
assertThat(Util.toPosix(TimeZone.getTimeZone("PST"), true),
anyOf(is("PST-8PDT1,M3.2.0/2,M11.1.0/2"),
is("GMT-08:00-8GMT-07:001,M3.2.0/2,M11.1.0/2")));

// Tokyo has +ve offset, no DST
assertEquals(
"JST9",
Util.toPosix(TimeZone.getTimeZone("Asia/Tokyo"), true));

// Sydney, Australia lies ten hours east of GMT and makes a one hour
assertThat(
Util.toPosix(TimeZone.getTimeZone("Asia/Tokyo"), true),
anyOf(
// Before JDK 23
is("JST9"),
// JDK 23 and later
is("GMT+09:009")));

// Sydney, Australia lies ten hours east of GMT and makes a one-hour
// shift forward during daylight savings. Being located in the southern
// hemisphere, daylight savings begins on the last Sunday in October at
// 2am and ends on the last Sunday in March at 3am.
Expand All @@ -676,28 +675,24 @@ private List<Integer> makeConsList(int start, int end) {
// have a different (older and incorrect) timezone settings for
// Australia. So we test for the older one first then do the
// correct assert based upon what the toPosix method returns
String posixTime =
Util.toPosix(TimeZone.getTimeZone("Australia/Sydney"), true);

if (posixTime.equals("EST10EST1,M10.5.0/2,M3.5.0/3")) {
// very old JVMs without the fix
assertEquals("EST10EST1,M10.5.0/2,M3.5.0/3", posixTime);
} else if (posixTime.equals("EST10EST1,M10.1.0/2,M4.1.0/3")) {
// old JVMs without the fix
assertEquals("EST10EST1,M10.1.0/2,M4.1.0/3", posixTime);
} else {
// newer JVMs with the fix
assertEquals("AEST10AEDT1,M10.1.0/2,M4.1.0/3", posixTime);
}
assertThat(Util.toPosix(TimeZone.getTimeZone("Australia/Sydney"), true),
anyOf(
// very old JVMs without the fix
is("EST10EST1,M10.5.0/2,M3.5.0/3"),
// old JVMs without the fix
is("EST10EST1,M10.1.0/2,M4.1.0/3"),
// newer JVMs with the fix
is("AEST10AEDT1,M10.1.0/2,M4.1.0/3"),
// JDK 23 and later
is("GMT+10:0010GMT+11:001,M10.1.0/2,M4.1.0/3")));

// Paris, France. (Uses UTC_TIME time-transition mode.)
assertEquals(
"CET1CEST1,M3.5.0/2,M10.5.0/3",
Util.toPosix(TimeZone.getTimeZone("Europe/Paris"), true));
assertThat(Util.toPosix(TimeZone.getTimeZone("Europe/Paris"), true),
anyOf(is("CET1CEST1,M3.5.0/2,M10.5.0/3"),
is("GMT+01:001GMT+02:001,M3.5.0/2,M10.5.0/3")));

assertEquals(
"UTC0",
Util.toPosix(TimeZone.getTimeZone("UTC"), true));
assertThat(Util.toPosix(TimeZone.getTimeZone("UTC"), true),
is("UTC0"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static QueryBuilder analyze(RexNode expression) throws ExpressionNotAnalyzableEx
}
return e != null ? e.builder() : null;
} catch (Throwable e) {
Throwables.propagateIfPossible(e, UnsupportedOperationException.class);
Throwables.throwIfInstanceOf(e, UnsupportedOperationException.class);
throw new ExpressionNotAnalyzableException("Can't convert " + expression, e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ foodmart-data-hsqldb.version=0.5
foodmart-data-json.version=0.4
foodmart-queries.version=0.4.1
geode-core.version=1.15.1
guava.version=32.1.3-jre
guava.version=33.3.0-jre
h2.version=2.1.210
hadoop.version=2.7.5
hadoop.version=2.10.2
hamcrest-date.version=2.0.4
hamcrest.version=2.1
hsqldb.version=2.7.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.apache.calcite.piglet.PigConverter;
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.tools.FrameworkConfig;
import org.apache.calcite.util.TestUtil;

import org.junit.jupiter.api.BeforeEach;

Expand All @@ -39,6 +40,8 @@ public abstract class PigRelTestBase {
public void testSetup() throws Exception {
assumeFalse(getProperty("os.name").startsWith("Windows"),
"Skip: Pig/Hadoop tests do not work on Windows");
assumeFalse(TestUtil.getJavaMajorVersion() >= 23,
"Skip: Pig/Hadoop tests do not work on JDK 23 and higher");

final FrameworkConfig config = config().build();
converter = create(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@
*/
package org.apache.calcite.chinook;

import org.apache.calcite.util.TestUtil;
import org.apache.calcite.util.Version;

import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import static org.junit.jupiter.api.Assumptions.assumeFalse;

/**
* Tests against parameters in prepared statement when using underlying JDBC
* sub-schema.
*/
class RemotePreparedStatementParametersTest {

@Test void testSimpleStringParameterShouldWorkWithCalcite() throws Exception {
assumeFalse(TestUtil.getJavaMajorVersion() >= 23
&& TestUtil.AVATICA_VERSION.compareTo(Version.of(1, 25)) > 0,
"Cannot run on JDK 23 and higher with Avatica version 1.25 or lower; "
+ "enable when [CALCITE-6588] is fixed in Avatica");

// given
ChinookAvaticaServer server = new ChinookAvaticaServer();
server.startWithCalcite();
Expand All @@ -44,6 +54,11 @@ class RemotePreparedStatementParametersTest {
}

@Test void testSeveralParametersShouldWorkWithCalcite() throws Exception {
assumeFalse(TestUtil.getJavaMajorVersion() >= 23
&& TestUtil.AVATICA_VERSION.compareTo(Version.of(1, 25)) > 0,
"Cannot run on JDK 23 and higher with Avatica version 1.25 or lower; "
+ "enable when [CALCITE-6588] is fixed in Avatica");

// given
ChinookAvaticaServer server = new ChinookAvaticaServer();
server.startWithCalcite();
Expand All @@ -60,6 +75,11 @@ class RemotePreparedStatementParametersTest {
}

@Test void testParametersShouldWorkWithRaw() throws Exception {
assumeFalse(TestUtil.getJavaMajorVersion() >= 23
&& TestUtil.AVATICA_VERSION.compareTo(Version.of(1, 25)) > 0,
"Cannot run on JDK 23 and higher with Avatica version 1.25 or lower; "
+ "enable when [CALCITE-6588] is fixed in Avatica");

// given
ChinookAvaticaServer server = new ChinookAvaticaServer();
server.startWithRaw();
Expand Down
4 changes: 2 additions & 2 deletions site/_docs/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ calculations that use DECIMAL values to produce slightly different
results.

Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
using JDK/OpenJDK versions 8 to 19;
Guava versions 21.0 to 32.1.3-jre;
using JDK/OpenJDK versions 8 to 23;
Guava versions 21.0 to 33.3.0-jre;
other software versions as specified in gradle.properties.

#### New features
Expand Down
Loading

0 comments on commit e314fcc

Please sign in to comment.