You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2022/05/07 00:55:09 UTC

[calcite] branch main updated: [CALCITE-5095] Support Java 18 and Guava 31.1-jre

This is an automated email from the ASF dual-hosted git repository.

jhyde pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new ff783a8cca [CALCITE-5095] Support Java 18 and Guava 31.1-jre
ff783a8cca is described below

commit ff783a8cca8caecd40b765daa1d6c4f640831c84
Author: Benchao Li <li...@gmail.com>
AuthorDate: Mon Apr 18 11:33:11 2022 +0800

    [CALCITE-5095] Support Java 18 and Guava 31.1-jre
    
    Update Travis URL.
    
    Close apache/calcite#2773
---
 .github/workflows/main.yml                                 |  8 ++++----
 .travis.yml                                                | 13 ++++++++-----
 .../org/apache/calcite/config/CalciteSystemProperty.java   |  5 ++++-
 .../apache/calcite/plan/volcano/IterativeRuleQueue.java    |  4 +++-
 .../org/apache/calcite/rel/externalize/RelEnumTypes.java   | 12 +++++++++---
 .../org/apache/calcite/rel/rules/JoinToMultiJoinRule.java  |  4 ++--
 .../main/java/org/apache/calcite/rel/rules/MultiJoin.java  |  4 +++-
 .../java/org/apache/calcite/rex/RexFieldCollation.java     |  4 +++-
 core/src/main/java/org/apache/calcite/rex/RexShuttle.java  |  4 +++-
 .../apache/calcite/sql/parser/SqlAbstractParserImpl.java   |  2 ++
 .../java/org/apache/calcite/sql2rel/RelDecorrelator.java   | 14 +++++++-------
 .../apache/calcite/statistic/MapSqlStatisticProvider.java  |  4 +++-
 gradle.properties                                          |  2 +-
 site/_docs/history.md                                      |  7 ++++++-
 site/_docs/howto.md                                        |  4 ++--
 15 files changed, 60 insertions(+), 31 deletions(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index ca52eb5322..60f20e59f5 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -155,23 +155,23 @@ jobs:
 
   mac:
     if: github.event.action != 'labeled'
-    name: 'macOS (JDK 17)'
+    name: 'macOS (JDK 18)'
     runs-on: macos-latest
     steps:
       - uses: actions/checkout@v2
         with:
           fetch-depth: 50
-      - name: 'Set up JDK 17'
+      - name: 'Set up JDK 18'
         uses: actions/setup-java@v1
         with:
-          java-version: 17
+          java-version: 18
       - uses: burrunan/gradle-cache-action@v1
         name: Test
         env:
           S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
           S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
         with:
-          job-id: jdk17
+          job-id: jdk18
           remote-build-cache-proxy-enabled: false
           arguments: --scan --no-parallel --no-daemon build javadoc
       - name: 'sqlline and sqllsh'
diff --git a/.travis.yml b/.travis.yml
index 1a2c85c99c..36cea90b63 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,7 +16,7 @@
 #
 
 # Configuration file for Travis continuous integration.
-# See https://travis-ci.org/apache/calcite
+# See https://travis-ci.com/github/apache/calcite
 language: java
 matrix:
   fast_finish: true
@@ -34,7 +34,7 @@ matrix:
     - jdk: openjdk11
       env:
         - ERRORPRONE=Y
-        - GUAVA=31.0.1-jre # ErrorProne checks for Beta APIs, so use newest supported Guava version
+        - GUAVA=31.1-jre # ErrorProne checks for Beta APIs, so use newest supported Guava version
       script:
         - export _JAVA_OPTIONS="-XX:GCTimeLimit=90 -XX:GCHeapFreeLimit=35"
         - ./gradlew --no-parallel --no-daemon --scan -Pguava.version=${GUAVA:-29.0-jre} -PenableErrorprone classes
@@ -43,13 +43,16 @@ matrix:
         - TZ=Pacific/Chatham # flips between +12:45 and +13:45
     - jdk: openjdk15
       env:
-        - GUAVA=31.0.1-jre # newest supported Guava version
+        - GUAVA=31.1-jre # newest supported Guava version
     - jdk: openjdk16
       env:
-        - GUAVA=31.0.1-jre
+        - GUAVA=31.1-jre
     - jdk: openjdk17
       env:
-        - GUAVA=31.0.1-jre
+        - GUAVA=31.1-jre
+    - jdk: openjdk18
+      env:
+        - GUAVA=31.1-jre
 branches:
   only:
     - main
diff --git a/core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java b/core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java
index fd7e90a1ec..0b92204247 100644
--- a/core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java
+++ b/core/src/main/java/org/apache/calcite/config/CalciteSystemProperty.java
@@ -31,6 +31,8 @@ import java.util.function.Function;
 import java.util.function.IntPredicate;
 import java.util.stream.Stream;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * A Calcite specific system property that is used to configure various aspects of the framework.
  *
@@ -429,7 +431,8 @@ public final class CalciteSystemProperty<T> {
         Thread.currentThread().getContextClassLoader(),
         CalciteSystemProperty.class.getClassLoader());
     // Read properties from the file "saffron.properties", if it exists in classpath
-    try (InputStream stream = classLoader.getResourceAsStream("saffron.properties")) {
+    try (InputStream stream = requireNonNull(classLoader, "classLoader")
+        .getResourceAsStream("saffron.properties")) {
       if (stream != null) {
         saffronProperties.load(stream);
       }
diff --git a/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java b/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
index 1f4ee28eb8..81976b4877 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
@@ -33,6 +33,8 @@ import java.util.HashSet;
 import java.util.Queue;
 import java.util.Set;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * Priority queue of relexps whose rules have not been called, and rule-matches
  * which have not yet been acted upon.
@@ -87,7 +89,7 @@ class IterativeRuleQueue extends RuleQueue {
     matchList.offer(match);
 
     matchList.matchMap.put(
-        planner.getSubset(match.rels[0]), match);
+        requireNonNull(planner.getSubset(match.rels[0])), match);
   }
 
   /**
diff --git a/core/src/main/java/org/apache/calcite/rel/externalize/RelEnumTypes.java b/core/src/main/java/org/apache/calcite/rel/externalize/RelEnumTypes.java
index e72536fa87..97181d035d 100644
--- a/core/src/main/java/org/apache/calcite/rel/externalize/RelEnumTypes.java
+++ b/core/src/main/java/org/apache/calcite/rel/externalize/RelEnumTypes.java
@@ -33,10 +33,13 @@ import org.apache.calcite.sql.fun.SqlTrimFunction;
 
 import com.google.common.collect.ImmutableMap;
 
+import org.checkerframework.checker.nullness.qual.NonNull;
 import org.checkerframework.checker.nullness.qual.Nullable;
 
 import static org.apache.calcite.linq4j.Nullness.castNonNull;
 
+import static java.util.Objects.requireNonNull;
+
 /** Registry of {@link Enum} classes that can be serialized to JSON.
  *
  * <p>Suppose you want to serialize the value
@@ -103,8 +106,11 @@ public abstract class RelEnumTypes {
   }
 
   /** Converts a string to an enum value.
-   * The converse of {@link #fromEnum(Enum)}. */
-  static <E extends Enum<E>> E toEnum(String name) {
-    return (E) ENUM_BY_NAME.get(name);
+   * The converse of {@link #fromEnum(Enum)}.
+   *
+   * @throws NullPointerException if there is no corresponding registered {@link Enum}
+   * */
+  static <E extends Enum<E>> @NonNull E toEnum(String name) {
+    return (E) requireNonNull(ENUM_BY_NAME.get(name));
   }
 }
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/JoinToMultiJoinRule.java b/core/src/main/java/org/apache/calcite/rel/rules/JoinToMultiJoinRule.java
index 8c076870ad..f06593511f 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/JoinToMultiJoinRule.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/JoinToMultiJoinRule.java
@@ -226,7 +226,7 @@ public class JoinToMultiJoinRule
         newInputs.add(leftMultiJoin.getInput(i));
         projFieldsList.add(leftMultiJoin.getProjFields().get(i));
         joinFieldRefCountsList.add(
-            leftMultiJoin.getJoinFieldRefCountsMap().get(i).toIntArray());
+            requireNonNull(leftMultiJoin.getJoinFieldRefCountsMap().get(i)).toIntArray());
       }
     } else {
       newInputs.add(left);
@@ -242,7 +242,7 @@ public class JoinToMultiJoinRule
         projFieldsList.add(
             rightMultiJoin.getProjFields().get(i));
         joinFieldRefCountsList.add(
-            rightMultiJoin.getJoinFieldRefCountsMap().get(i).toIntArray());
+            requireNonNull(rightMultiJoin.getJoinFieldRefCountsMap().get(i)).toIntArray());
       }
     } else {
       newInputs.add(right);
diff --git a/core/src/main/java/org/apache/calcite/rel/rules/MultiJoin.java b/core/src/main/java/org/apache/calcite/rel/rules/MultiJoin.java
index b7dd3a7833..49000fe2fb 100644
--- a/core/src/main/java/org/apache/calcite/rel/rules/MultiJoin.java
+++ b/core/src/main/java/org/apache/calcite/rel/rules/MultiJoin.java
@@ -42,6 +42,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * A MultiJoin represents a join of N inputs, whereas regular Joins
  * represent strictly binary joins.
@@ -140,7 +142,7 @@ public final class MultiJoin extends AbstractRelNode {
   private Map<Integer, int[]> cloneJoinFieldRefCountsMap() {
     Map<Integer, int[]> clonedMap = new HashMap<>();
     for (int i = 0; i < inputs.size(); i++) {
-      clonedMap.put(i, joinFieldRefCountsMap.get(i).toIntArray());
+      clonedMap.put(i, requireNonNull(joinFieldRefCountsMap.get(i)).toIntArray());
     }
     return clonedMap;
   }
diff --git a/core/src/main/java/org/apache/calcite/rex/RexFieldCollation.java b/core/src/main/java/org/apache/calcite/rex/RexFieldCollation.java
index 53243550b1..9f80626253 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexFieldCollation.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexFieldCollation.java
@@ -26,6 +26,8 @@ import com.google.common.collect.Sets;
 
 import java.util.Set;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * Expression combined with sort flags (DESCENDING, NULLS LAST).
  */
@@ -44,7 +46,7 @@ public class RexFieldCollation extends Pair<RexNode, ImmutableSet<SqlKind>> {
           .build();
 
   public RexFieldCollation(RexNode left, Set<SqlKind> right) {
-    super(left, KINDS.get(right));
+    super(left, requireNonNull(KINDS.get(right)));
   }
 
   @Override public String toString() {
diff --git a/core/src/main/java/org/apache/calcite/rex/RexShuttle.java b/core/src/main/java/org/apache/calcite/rex/RexShuttle.java
index f546a50ca9..718d361591 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexShuttle.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexShuttle.java
@@ -24,6 +24,8 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
 import java.util.ArrayList;
 import java.util.List;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * Passes over a row-expression, calling a handler method for each node,
  * appropriate to the type of the node.
@@ -185,7 +187,7 @@ public class RexShuttle implements RexVisitor<RexNode> {
       if ((clonedOperand != collation.left) && (update != null)) {
         update[0] = true;
         collation =
-            new RexFieldCollation(clonedOperand, collation.right);
+            new RexFieldCollation(clonedOperand, requireNonNull(collation.right));
       }
       clonedOperands.add(collation);
     }
diff --git a/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java b/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
index 8afbfd8ce7..cab77f96a3 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
@@ -35,6 +35,7 @@ import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 
 import org.checkerframework.checker.initialization.qual.UnderInitialization;
+import org.checkerframework.checker.nullness.qual.NonNull;
 import org.checkerframework.checker.nullness.qual.Nullable;
 
 import java.io.Reader;
@@ -378,6 +379,7 @@ public abstract class SqlAbstractParserImpl {
    * @param operands          Operands to call
    * @return Call
    */
+  @SuppressWarnings("argument.type.incompatible")
   protected SqlCall createCall(
       SqlIdentifier funName,
       SqlParserPos pos,
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index 7acfd46f29..34f3205cf6 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -545,7 +545,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
 
       // add mapping of group keys.
       outputMap.put(i, newPos);
-      int newInputPos = frame.oldToNewOutputs.get(i);
+      int newInputPos = requireNonNull(frame.oldToNewOutputs.get(i));
       projects.add(RexInputRef.of2(newInputPos, newInputOutput));
       mapNewInputToProjOutputs.put(newInputPos, newPos);
       newPos++;
@@ -833,7 +833,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
         newLocalOutputs = mapNewInputToOutputs.get(newInput);
       }
 
-      final int newCorVarOffset = frame.oldToNewOutputs.get(oldCorVarOffset);
+      final int newCorVarOffset = requireNonNull(frame.oldToNewOutputs.get(oldCorVarOffset));
 
       // Add all unique positions referenced.
       if (!newLocalOutputs.contains(newCorVarOffset)) {
@@ -897,7 +897,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
       final List<Integer> newLocalOutputs = requireNonNull(mapNewInputToOutputs.get(newInput),
           () -> "mapNewInputToOutputs.get(" + newInput + ")");
 
-      final int newLocalOutput = frame.oldToNewOutputs.get(corRef.field);
+      final int newLocalOutput = requireNonNull(frame.oldToNewOutputs.get(corRef.field));
 
       // newOutput is the index of the corVar in the referenced
       // position list plus the offset of referenced position list of
@@ -1220,7 +1220,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
       if (!corDef.corr.equals(rel.getCorrelationId())) {
         continue;
       }
-      final int newLeftPos = leftFrame.oldToNewOutputs.get(corDef.field);
+      final int newLeftPos = requireNonNull(leftFrame.oldToNewOutputs.get(corDef.field));
       final int newRightPos = rightOutput.getValue();
       conditions.add(
           relBuilder.equals(RexInputRef.of(newLeftPos, newLeftOutput),
@@ -1258,7 +1258,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
     // Right input positions are shifted by newLeftFieldCount.
     for (int i = 0; i < oldRightFieldCount; i++) {
       mapOldToNewOutputs.put(i + oldLeftFieldCount,
-          rightFrame.oldToNewOutputs.get(i) + newLeftFieldCount);
+          requireNonNull(rightFrame.oldToNewOutputs.get(i)) + newLeftFieldCount);
     }
 
     final RexNode condition =
@@ -1325,7 +1325,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
     // Right input positions are shifted by newLeftFieldCount.
     for (int i = 0; i < oldRightFieldCount; i++) {
       mapOldToNewOutputs.put(i + oldLeftFieldCount,
-          rightFrame.oldToNewOutputs.get(i) + newLeftFieldCount);
+          requireNonNull(rightFrame.oldToNewOutputs.get(i)) + newLeftFieldCount);
     }
 
     final NavigableMap<CorDef, Integer> corDefOutputs =
@@ -1376,7 +1376,7 @@ public class RelDecorrelator implements ReflectiveVisitor {
     int newLocalOrdinal = oldLocalOrdinal;
 
     if (!frame.oldToNewOutputs.isEmpty()) {
-      newLocalOrdinal = frame.oldToNewOutputs.get(oldLocalOrdinal);
+      newLocalOrdinal = requireNonNull(frame.oldToNewOutputs.get(oldLocalOrdinal));
     }
 
     newOrdinal += newLocalOrdinal;
diff --git a/core/src/main/java/org/apache/calcite/statistic/MapSqlStatisticProvider.java b/core/src/main/java/org/apache/calcite/statistic/MapSqlStatisticProvider.java
index b304e86d09..1c4e85c829 100644
--- a/core/src/main/java/org/apache/calcite/statistic/MapSqlStatisticProvider.java
+++ b/core/src/main/java/org/apache/calcite/statistic/MapSqlStatisticProvider.java
@@ -28,6 +28,8 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
+import static java.util.Objects.requireNonNull;
+
 /**
  * Implementation of {@link SqlStatisticProvider} that looks up values in a
  * table.
@@ -103,7 +105,7 @@ public enum MapSqlStatisticProvider implements SqlStatisticProvider {
             .map(value ->
                 Arrays.asList(value.jdbcSchemaName, value.jdbcTableName))
             .orElseGet(table::getQualifiedName);
-    return cardinalityMap.get(qualifiedName.toString());
+    return requireNonNull(cardinalityMap.get(qualifiedName.toString()));
   }
 
   @Override public boolean isForeignKey(RelOptTable fromTable, List<Integer> fromColumns,
diff --git a/gradle.properties b/gradle.properties
index 1aabc6464e..923d777b5e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -100,7 +100,7 @@ foodmart-data-hsqldb.version=0.5
 foodmart-data-json.version=0.4
 foodmart-queries.version=0.4.1
 geode-core.version=1.10.0
-guava.version=29.0-jre
+guava.version=31.1-jre
 h2.version=2.1.210
 hadoop.version=2.7.5
 hamcrest-date.version=2.0.4
diff --git a/site/_docs/history.md b/site/_docs/history.md
index 3433968d01..eaa1a2efdc 100644
--- a/site/_docs/history.md
+++ b/site/_docs/history.md
@@ -29,7 +29,7 @@ Downloads are available on the
 [downloads page]({{ site.baseurl }}/downloads/).
 
 {% comment %}
-## <a href="https://github.com/apache/calcite/releases/tag/calcite-1.31.0">1.31.0</a> / 2022-MM-DD
+## <a href="https://github.com/apache/calcite/releases/tag/calcite-1.31.0">1.31.0</a> / TODO
 {: #v1-31-0}
 
 #### Breaking Changes
@@ -38,6 +38,11 @@ Downloads are available on the
 * [<a href="https://issues.apache.org/jira/browse/CALCITE-4936">CALCITE-4936</a>]
   Generalize `FilterCalcMergeRule`/`ProjectCalcMergeRule` to accept any `Filter`/`Project`/`Calc` operator
 
+Compatibility: This release is tested on Linux, macOS, Microsoft Windows;
+using JDK/OpenJDK versions 8 to 18;
+Guava versions 19.0 to 31.1-jre;
+other software versions as specified in gradle.properties.
+
 #### New features
 {: #new-features-1-31-0}
 
diff --git a/site/_docs/howto.md b/site/_docs/howto.md
index dd5f477be3..6543995ca6 100644
--- a/site/_docs/howto.md
+++ b/site/_docs/howto.md
@@ -31,7 +31,7 @@ adapters.
 
 ## Building from a source distribution
 
-Prerequisite is Java (JDK 8, 9, 10, 11, 12, 13, 14, 15, 16 or 17)
+Prerequisite is Java (JDK 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 or 18)
 and Gradle (version 7.3) on your path.
 
 Unpack the source distribution `.tar.gz` file,
@@ -51,7 +51,7 @@ tests  (but you should use the `gradle` command rather than
 ## Building from Git
 
 Prerequisites are git
-and Java (JDK 8, 9, 10, 11, 12, 13, 14, 15, 16 or 17) on your path.
+and Java (JDK 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 or 18) on your path.
 
 Create a local copy of the GitHub repository,
 `cd` to its root directory,