http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java 
b/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
index b797ef9..dbf6389 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
@@ -26,6 +26,7 @@ import org.apache.calcite.util.ImmutableNullableList;
 import com.google.common.base.Preconditions;
 
 import java.util.List;
+import java.util.Objects;
 import javax.annotation.Nonnull;
 
 /**
@@ -75,20 +76,20 @@ public class SqlMatchRecognize extends SqlCall {
       SqlLiteral rowsPerMatch, SqlNodeList partitionList,
       SqlNodeList orderList, SqlLiteral interval) {
     super(pos);
-    this.tableRef = Preconditions.checkNotNull(tableRef);
-    this.pattern = Preconditions.checkNotNull(pattern);
+    this.tableRef = Objects.requireNonNull(tableRef);
+    this.pattern = Objects.requireNonNull(pattern);
     this.strictStart = strictStart;
     this.strictEnd = strictEnd;
-    this.patternDefList = Preconditions.checkNotNull(patternDefList);
+    this.patternDefList = Objects.requireNonNull(patternDefList);
     Preconditions.checkArgument(patternDefList.size() > 0);
-    this.measureList = Preconditions.checkNotNull(measureList);
+    this.measureList = Objects.requireNonNull(measureList);
     this.after = after;
     this.subsetList = subsetList;
     Preconditions.checkArgument(rowsPerMatch == null
         || rowsPerMatch.value instanceof RowsPerMatchOption);
     this.rowsPerMatch = rowsPerMatch;
-    this.partitionList = Preconditions.checkNotNull(partitionList);
-    this.orderList = Preconditions.checkNotNull(orderList);
+    this.partitionList = Objects.requireNonNull(partitionList);
+    this.orderList = Objects.requireNonNull(orderList);
     this.interval = interval;
   }
 
@@ -119,7 +120,7 @@ public class SqlMatchRecognize extends SqlCall {
   @Override public void setOperand(int i, SqlNode operand) {
     switch (i) {
     case OPERAND_TABLE_REF:
-      tableRef = Preconditions.checkNotNull(operand);
+      tableRef = Objects.requireNonNull(operand);
       break;
     case OPERAND_PATTERN:
       pattern = operand;
@@ -131,11 +132,11 @@ public class SqlMatchRecognize extends SqlCall {
       strictEnd = (SqlLiteral) operand;
       break;
     case OPERAND_PATTERN_DEFINES:
-      patternDefList = Preconditions.checkNotNull((SqlNodeList) operand);
+      patternDefList = Objects.requireNonNull((SqlNodeList) operand);
       Preconditions.checkArgument(patternDefList.size() > 0);
       break;
     case OPERAND_MEASURES:
-      measureList = Preconditions.checkNotNull((SqlNodeList) operand);
+      measureList = Objects.requireNonNull((SqlNodeList) operand);
       break;
     case OPERAND_AFTER:
       after = operand;

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlNode.java 
b/core/src/main/java/org/apache/calcite/sql/SqlNode.java
index 97080ab..c6d7d0b 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlNode.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlNode.java
@@ -28,10 +28,9 @@ import org.apache.calcite.sql.validate.SqlValidatorScope;
 import org.apache.calcite.util.Litmus;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Preconditions;
-
 import java.util.Collection;
 import java.util.List;
+import java.util.Objects;
 import java.util.Set;
 
 /**
@@ -58,7 +57,7 @@ public abstract class SqlNode implements Cloneable {
    * @param pos Parser position, must not be null.
    */
   SqlNode(SqlParserPos pos) {
-    this.pos = Preconditions.checkNotNull(pos);
+    this.pos = Objects.requireNonNull(pos);
   }
 
   //~ Methods ----------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java 
b/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
index b538013..2367afa 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlNodeList.java
@@ -172,7 +172,7 @@ public class SqlNodeList extends SqlNode implements 
Iterable<SqlNode> {
   }
 
   public SqlNode[] toArray() {
-    return list.toArray(new SqlNode[list.size()]);
+    return list.toArray(new SqlNode[0]);
   }
 
   public static boolean isEmptyList(final SqlNode node) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java 
b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
index c979c01..c4c092e 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
@@ -296,7 +296,7 @@ public abstract class SqlOperator {
     return createCall(
         null,
         pos,
-        operandList.toArray(new SqlNode[operandList.size()]));
+        operandList.toArray(new SqlNode[0]));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlSelect.java 
b/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
index 61b0157..ad7d6ef 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlSelect.java
@@ -21,9 +21,8 @@ import org.apache.calcite.sql.validate.SqlValidator;
 import org.apache.calcite.sql.validate.SqlValidatorScope;
 import org.apache.calcite.util.ImmutableNullableList;
 
-import com.google.common.base.Preconditions;
-
 import java.util.List;
+import java.util.Objects;
 import javax.annotation.Nonnull;
 
 /**
@@ -65,14 +64,14 @@ public class SqlSelect extends SqlCall {
       SqlNode offset,
       SqlNode fetch) {
     super(pos);
-    this.keywordList = Preconditions.checkNotNull(keywordList != null
+    this.keywordList = Objects.requireNonNull(keywordList != null
         ? keywordList : new SqlNodeList(pos));
     this.selectList = selectList;
     this.from = from;
     this.where = where;
     this.groupBy = groupBy;
     this.having = having;
-    this.windowDecls = Preconditions.checkNotNull(windowDecls != null
+    this.windowDecls = Objects.requireNonNull(windowDecls != null
         ? windowDecls : new SqlNodeList(pos));
     this.orderBy = orderBy;
     this.offset = offset;
@@ -97,7 +96,7 @@ public class SqlSelect extends SqlCall {
   @Override public void setOperand(int i, SqlNode operand) {
     switch (i) {
     case 0:
-      keywordList = Preconditions.checkNotNull((SqlNodeList) operand);
+      keywordList = Objects.requireNonNull((SqlNodeList) operand);
       break;
     case 1:
       selectList = (SqlNodeList) operand;
@@ -115,7 +114,7 @@ public class SqlSelect extends SqlCall {
       having = operand;
       break;
     case 6:
-      windowDecls = Preconditions.checkNotNull((SqlNodeList) operand);
+      windowDecls = Objects.requireNonNull((SqlNodeList) operand);
       break;
     case 7:
       orderBy = (SqlNodeList) operand;

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlSetOption.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlSetOption.java 
b/core/src/main/java/org/apache/calcite/sql/SqlSetOption.java
index 8538ffc..2cfe894 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlSetOption.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlSetOption.java
@@ -21,8 +21,7 @@ import org.apache.calcite.sql.validate.SqlValidator;
 import org.apache.calcite.sql.validate.SqlValidatorScope;
 import org.apache.calcite.util.ImmutableNullableList;
 
-import com.google.common.collect.Lists;
-
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -107,7 +106,7 @@ public class SqlSetOption extends SqlAlter {
   }
 
   @Override public List<SqlNode> getOperandList() {
-    final List<SqlNode> operandList = Lists.newArrayList();
+    final List<SqlNode> operandList = new ArrayList<>();
     if (scope == null) {
       operandList.add(null);
     } else {

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlSpecialOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlSpecialOperator.java 
b/core/src/main/java/org/apache/calcite/sql/SqlSpecialOperator.java
index 83049ac..9587c2a 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlSpecialOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlSpecialOperator.java
@@ -23,7 +23,7 @@ import org.apache.calcite.sql.type.SqlReturnTypeInference;
 import org.apache.calcite.util.PrecedenceClimbingParser;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Predicate;
+import java.util.function.Predicate;
 
 /**
  * Generic operator for nodes with special syntax.

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlUtil.java 
b/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
index ae3f144..52ba9a4 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlUtil.java
@@ -17,14 +17,12 @@
 package org.apache.calcite.sql;
 
 import org.apache.calcite.linq4j.Ord;
-import org.apache.calcite.linq4j.function.Function1;
 import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.rel.type.RelDataTypePrecedenceList;
 import org.apache.calcite.runtime.CalciteContextException;
 import org.apache.calcite.runtime.CalciteException;
-import org.apache.calcite.runtime.PredicateImpl;
 import org.apache.calcite.runtime.Resources;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParserPos;
@@ -39,10 +37,8 @@ import org.apache.calcite.util.NlsString;
 import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
 import com.google.common.collect.Lists;
 
@@ -56,6 +52,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -71,7 +70,7 @@ public abstract class SqlUtil {
     if (node1 == null) {
       return node2;
     }
-    ArrayList<SqlNode> list = new ArrayList<SqlNode>();
+    ArrayList<SqlNode> list = new ArrayList<>();
     if (node1.getKind() == SqlKind.AND) {
       list.addAll(((SqlCall) node1).getOperandList());
     } else {
@@ -88,7 +87,7 @@ public abstract class SqlUtil {
   }
 
   static ArrayList<SqlNode> flatten(SqlNode node) {
-    ArrayList<SqlNode> list = new ArrayList<SqlNode>();
+    ArrayList<SqlNode> list = new ArrayList<>();
     flatten(node, list);
     return list;
   }
@@ -386,11 +385,7 @@ public abstract class SqlUtil {
   private static Iterator<SqlOperator> filterOperatorRoutinesByKind(
       Iterator<SqlOperator> routines, final SqlKind sqlKind) {
     return Iterators.filter(routines,
-        new PredicateImpl<SqlOperator>() {
-          public boolean test(SqlOperator input) {
-            return input.getKind() == sqlKind;
-          }
-        });
+        operator -> Objects.requireNonNull(operator).getKind() == sqlKind);
   }
 
   /**
@@ -489,11 +484,7 @@ public abstract class SqlUtil {
           Predicates.instanceOf(SqlFunction.class));
     default:
       return Iterators.filter(sqlOperators.iterator(),
-          new PredicateImpl<SqlOperator>() {
-            public boolean test(SqlOperator operator) {
-              return operator.getSyntax() == syntax;
-            }
-          });
+          operator -> Objects.requireNonNull(operator).getSyntax() == syntax);
     }
   }
 
@@ -501,12 +492,8 @@ public abstract class SqlUtil {
       Iterator<SqlOperator> routines,
       final List<RelDataType> argTypes) {
     return Iterators.filter(routines,
-        new PredicateImpl<SqlOperator>() {
-          public boolean test(SqlOperator operator) {
-            SqlOperandCountRange od = operator.getOperandCountRange();
-            return od.isValidCount(argTypes.size());
-          }
-        });
+        operator -> Objects.requireNonNull(operator)
+            .getOperandCountRange().isValidCount(argTypes.size()));
   }
 
   /**
@@ -523,52 +510,48 @@ public abstract class SqlUtil {
     //noinspection unchecked
     return (Iterator) Iterators.filter(
         Iterators.filter(routines, SqlFunction.class),
-        new PredicateImpl<SqlFunction>() {
-          public boolean test(SqlFunction function) {
-            List<RelDataType> paramTypes = function.getParamTypes();
-            if (paramTypes == null) {
-              // no parameter information for builtins; keep for now
-              return true;
-            }
-            final List<RelDataType> permutedArgTypes;
-            if (argNames != null) {
-              // Arguments passed by name. Make sure that the function has
-              // parameters of all of these names.
-              final Map<Integer, Integer> map = new HashMap<>();
-              for (Ord<String> argName : Ord.zip(argNames)) {
-                final int i = function.getParamNames().indexOf(argName.e);
-                if (i < 0) {
-                  return false;
-                }
-                map.put(i, argName.i);
-              }
-              permutedArgTypes = Functions.generate(paramTypes.size(),
-                  new Function1<Integer, RelDataType>() {
-                    public RelDataType apply(Integer a0) {
-                      if (map.containsKey(a0)) {
-                        return argTypes.get(map.get(a0));
-                      } else {
-                        return null;
-                      }
-                    }
-                  });
-            } else {
-              permutedArgTypes = Lists.newArrayList(argTypes);
-              while (permutedArgTypes.size() < argTypes.size()) {
-                paramTypes.add(null);
+        function -> {
+          List<RelDataType> paramTypes =
+              Objects.requireNonNull(function).getParamTypes();
+          if (paramTypes == null) {
+            // no parameter information for builtins; keep for now
+            return true;
+          }
+          final List<RelDataType> permutedArgTypes;
+          if (argNames != null) {
+            // Arguments passed by name. Make sure that the function has
+            // parameters of all of these names.
+            final Map<Integer, Integer> map = new HashMap<>();
+            for (Ord<String> argName : Ord.zip(argNames)) {
+              final int i = function.getParamNames().indexOf(argName.e);
+              if (i < 0) {
+                return false;
               }
+              map.put(i, argName.i);
             }
-            for (Pair<RelDataType, RelDataType> p
-                : Pair.zip(paramTypes, permutedArgTypes)) {
-              final RelDataType argType = p.right;
-              final RelDataType paramType = p.left;
-              if (argType != null
-                  && !SqlTypeUtil.canCastFrom(paramType, argType, false)) {
-                return false;
+            permutedArgTypes = Functions.generate(paramTypes.size(), a0 -> {
+              if (map.containsKey(a0)) {
+                return argTypes.get(map.get(a0));
+              } else {
+                return null;
               }
+            });
+          } else {
+            permutedArgTypes = Lists.newArrayList(argTypes);
+            while (permutedArgTypes.size() < argTypes.size()) {
+              paramTypes.add(null);
+            }
+          }
+          for (Pair<RelDataType, RelDataType> p
+              : Pair.zip(paramTypes, permutedArgTypes)) {
+            final RelDataType argType = p.right;
+            final RelDataType paramType = p.left;
+            if (argType != null
+                && !SqlTypeUtil.canCastFrom(paramType, argType, false)) {
+              return false;
             }
-            return true;
           }
+          return true;
         });
   }
 
@@ -591,19 +574,16 @@ public abstract class SqlUtil {
           argType.e.getPrecedenceList();
       final RelDataType bestMatch = bestMatch(sqlFunctions, argType.i, 
precList);
       if (bestMatch != null) {
-        sqlFunctions =
-            Lists.newArrayList(
-                Iterables.filter(sqlFunctions,
-                    new PredicateImpl<SqlFunction>() {
-                      public boolean test(SqlFunction function) {
-                        final List<RelDataType> paramTypes = 
function.getParamTypes();
-                        if (paramTypes == null) {
-                          return false;
-                        }
-                        final RelDataType paramType = 
paramTypes.get(argType.i);
-                        return precList.compareTypePrecedence(paramType, 
bestMatch) >= 0;
-                      }
-                    }));
+        sqlFunctions = sqlFunctions.stream()
+            .filter(function -> {
+              final List<RelDataType> paramTypes = function.getParamTypes();
+              if (paramTypes == null) {
+                return false;
+              }
+              final RelDataType paramType = paramTypes.get(argType.i);
+              return precList.compareTypePrecedence(paramType, bestMatch) >= 0;
+            })
+            .collect(Collectors.toList());
       }
     }
     //noinspection unchecked
@@ -680,7 +660,7 @@ public abstract class SqlUtil {
       SqlOperatorTable opTab,
       SqlIdentifier id) {
     if (id.names.size() == 1) {
-      final List<SqlOperator> list = Lists.newArrayList();
+      final List<SqlOperator> list = new ArrayList<>();
       opTab.lookupOperatorOverloads(id, null, SqlSyntax.FUNCTION, list);
       for (SqlOperator operator : list) {
         if (operator.getSyntax() == SqlSyntax.FUNCTION_ID) {
@@ -928,7 +908,7 @@ public abstract class SqlUtil {
   /** Walks over a {@link org.apache.calcite.sql.SqlNode} tree and returns the
    * ancestry stack when it finds a given node. */
   private static class Genealogist extends SqlBasicVisitor<Void> {
-    private final List<SqlNode> ancestors = Lists.newArrayList();
+    private final List<SqlNode> ancestors = new ArrayList<>();
     private final Predicate<SqlNode> predicate;
     private final Predicate<SqlNode> postPredicate;
 
@@ -945,14 +925,14 @@ public abstract class SqlUtil {
     }
 
     private Void preCheck(SqlNode node) {
-      if (predicate.apply(node)) {
+      if (predicate.test(node)) {
         throw new Util.FoundOne(ImmutableList.copyOf(ancestors));
       }
       return null;
     }
 
     private Void postCheck(SqlNode node) {
-      if (postPredicate.apply(node)) {
+      if (postPredicate.test(node)) {
         throw new Util.FoundOne(ImmutableList.copyOf(ancestors));
       }
       return null;

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisor.java 
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisor.java
index 0216cc3..5395fac 100644
--- a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisor.java
+++ b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisor.java
@@ -18,7 +18,6 @@ package org.apache.calcite.sql.advise;
 
 import org.apache.calcite.runtime.CalciteContextException;
 import org.apache.calcite.runtime.CalciteException;
-import org.apache.calcite.runtime.PredicateImpl;
 import org.apache.calcite.sql.SqlIdentifier;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlSelect;
@@ -45,6 +44,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Locale;
+import java.util.Objects;
 
 /**
  * An assistant which offers hints and corrections to a partially-formed SQL
@@ -240,18 +240,11 @@ public class SqlAdvisor {
   private static boolean isSelectListItem(SqlNode root,
       final SqlParserPos pos) {
     List<SqlNode> nodes = SqlUtil.getAncestry(root,
-        new PredicateImpl<SqlNode>() {
-          public boolean test(SqlNode input) {
-            return input instanceof SqlIdentifier
-                && Util.last(((SqlIdentifier) input).names)
-                    .equals(UPPER_HINT_TOKEN);
-          }
-        },
-        new PredicateImpl<SqlNode>() {
-          public boolean test(SqlNode input) {
-            return input.getParserPosition().startsAt(pos);
-          }
-        });
+        input -> input instanceof SqlIdentifier
+            && Util.last(((SqlIdentifier) input).names)
+                .equals(UPPER_HINT_TOKEN),
+        input -> Objects.requireNonNull(input).getParserPosition()
+            .startsAt(pos));
     assert nodes.get(0) == root;
     nodes = Lists.reverse(nodes);
     return nodes.size() > 2

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
 
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
index da8d28e..155228d 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorGetHintsFunction.java
@@ -18,10 +18,8 @@ package org.apache.calcite.sql.advise;
 
 import org.apache.calcite.DataContext;
 import org.apache.calcite.adapter.enumerable.CallImplementor;
-import org.apache.calcite.adapter.enumerable.NotNullImplementor;
 import org.apache.calcite.adapter.enumerable.NullPolicy;
 import org.apache.calcite.adapter.enumerable.RexImpTable;
-import org.apache.calcite.adapter.enumerable.RexToLixTranslator;
 import org.apache.calcite.linq4j.Enumerable;
 import org.apache.calcite.linq4j.Linq4j;
 import org.apache.calcite.linq4j.tree.Expression;
@@ -29,7 +27,6 @@ import org.apache.calcite.linq4j.tree.Expressions;
 import org.apache.calcite.linq4j.tree.Types;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
-import org.apache.calcite.rex.RexCall;
 import org.apache.calcite.schema.FunctionParameter;
 import org.apache.calcite.schema.ImplementableFunction;
 import org.apache.calcite.schema.TableFunction;
@@ -63,13 +60,10 @@ public class SqlAdvisorGetHintsFunction
 
   private static final CallImplementor IMPLEMENTOR =
       RexImpTable.createImplementor(
-          new NotNullImplementor() {
-            public Expression implement(RexToLixTranslator translator,
-                RexCall call, List<Expression> operands) {
-              return Expressions.call(GET_COMPLETION_HINTS,
-                  Iterables.concat(Collections.singleton(ADVISOR), operands));
-            }
-          }, NullPolicy.ANY, false);
+          (translator, call, operands) ->
+              Expressions.call(GET_COMPLETION_HINTS,
+                  Iterables.concat(Collections.singleton(ADVISOR), operands)),
+          NullPolicy.ANY, false);
 
   private static final List<FunctionParameter> PARAMETERS =
       ReflectiveFunctionBase.builder()

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorHint.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorHint.java 
b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorHint.java
index 95bb404..915550a 100644
--- a/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorHint.java
+++ b/core/src/main/java/org/apache/calcite/sql/advise/SqlAdvisorHint.java
@@ -43,7 +43,7 @@ public class SqlAdvisorHint {
     final List<String> names = id.getFullyQualifiedNames();
     this.names = names == null
       ? null
-      : names.toArray(new String[names.size()]);
+      : names.toArray(new String[0]);
     type = id.getType().name();
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/dialect/JethroDataSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/JethroDataSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/JethroDataSqlDialect.java
index 26f0148..f945379 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/dialect/JethroDataSqlDialect.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/dialect/JethroDataSqlDialect.java
@@ -23,8 +23,6 @@ import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.sql.type.SqlTypeName;
 
-import com.google.common.base.Preconditions;
-
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSetMultimap;
 import com.google.common.collect.LinkedHashMultimap;
@@ -38,9 +36,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 
-
 /**
  * A <code>SqlDialect</code> implementation for the JethroData database.
  */
@@ -126,7 +124,7 @@ public class JethroDataSqlDialect extends SqlDialect {
     private final List<SqlTypeName> operandTypes;
 
     JethroSupportedFunction(String name, String operands) {
-      Preconditions.checkNotNull(name); // not currently used
+      Objects.requireNonNull(name); // not currently used
       final ImmutableList.Builder<SqlTypeName> b = ImmutableList.builder();
       for (String strType : operands.split(":")) {
         b.add(parse(strType));
@@ -222,7 +220,7 @@ public class JethroDataSqlDialect extends SqlDialect {
   /** Information about the capabilities of a Jethro database. */
   public static class JethroInfo {
     public static final JethroInfo EMPTY = new JethroInfo(
-        ImmutableSetMultimap.<String, JethroSupportedFunction>of());
+        ImmutableSetMultimap.of());
 
     private final ImmutableSetMultimap<String, JethroSupportedFunction> 
supportedFunctions;
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
index 22881de..6261481 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
@@ -33,8 +33,6 @@ import org.apache.calcite.sql.SqlWriter;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.type.ReturnTypes;
 
-
-
 /**
  * A <code>SqlDialect</code> implementation for the Microsoft SQL Server
  * database.

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/fun/OracleSqlOperatorTable.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/OracleSqlOperatorTable.java 
b/core/src/main/java/org/apache/calcite/sql/fun/OracleSqlOperatorTable.java
index a4a3175..f88d95d 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/OracleSqlOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/OracleSqlOperatorTable.java
@@ -21,7 +21,6 @@ import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.sql.SqlFunction;
 import org.apache.calcite.sql.SqlFunctionCategory;
 import org.apache.calcite.sql.SqlKind;
-import org.apache.calcite.sql.SqlOperatorBinding;
 import org.apache.calcite.sql.type.OperandTypes;
 import org.apache.calcite.sql.type.ReturnTypes;
 import org.apache.calcite.sql.type.SqlReturnTypeInference;
@@ -44,22 +43,20 @@ public class OracleSqlOperatorTable extends 
ReflectiveSqlOperatorTable {
 
   /** Return type inference for {@code DECODE}. */
   protected static final SqlReturnTypeInference DECODE_RETURN_TYPE =
-      new SqlReturnTypeInference() {
-        public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
-          final List<RelDataType> list = new ArrayList<>();
-          for (int i = 1, n = opBinding.getOperandCount(); i < n; i++) {
-            if (i < n - 1) {
-              ++i;
-            }
-            list.add(opBinding.getOperandType(i));
+      opBinding -> {
+        final List<RelDataType> list = new ArrayList<>();
+        for (int i = 1, n = opBinding.getOperandCount(); i < n; i++) {
+          if (i < n - 1) {
+            ++i;
           }
-          final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
-          RelDataType type = typeFactory.leastRestrictive(list);
-          if (opBinding.getOperandCount() % 2 == 1) {
-            type = typeFactory.createTypeWithNullability(type, true);
-          }
-          return type;
+          list.add(opBinding.getOperandType(i));
+        }
+        final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+        RelDataType type = typeFactory.leastRestrictive(list);
+        if (opBinding.getOperandCount() % 2 == 1) {
+          type = typeFactory.createTypeWithNullability(type, true);
         }
+        return type;
       };
 
   /** The "DECODE(v, v1, result1, [v2, result2, ...], resultN)" function. */

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/fun/SqlDatetimeSubtractionOperator.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlDatetimeSubtractionOperator.java
 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlDatetimeSubtractionOperator.java
index 1b78c12..7974d65 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlDatetimeSubtractionOperator.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlDatetimeSubtractionOperator.java
@@ -16,8 +16,6 @@
  */
 package org.apache.calcite.sql.fun;
 
-
-
 import org.apache.calcite.sql.SqlCall;
 import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.SqlOperatorBinding;

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/fun/SqlLeadLagAggFunction.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlLeadLagAggFunction.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlLeadLagAggFunction.java
index 5e5498b..d52c82b 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlLeadLagAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlLeadLagAggFunction.java
@@ -20,7 +20,6 @@ import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.sql.SqlAggFunction;
 import org.apache.calcite.sql.SqlFunctionCategory;
 import org.apache.calcite.sql.SqlKind;
-import org.apache.calcite.sql.SqlOperatorBinding;
 import org.apache.calcite.sql.type.OperandTypes;
 import org.apache.calcite.sql.type.ReturnTypes;
 import org.apache.calcite.sql.type.SameOperandTypeChecker;
@@ -56,21 +55,18 @@ public class SqlLeadLagAggFunction extends SqlAggFunction {
               }));
 
   private static final SqlReturnTypeInference RETURN_TYPE =
-      ReturnTypes.cascade(ReturnTypes.ARG0, new SqlTypeTransform() {
-        public RelDataType transformType(SqlOperatorBinding binding,
-            RelDataType type) {
-          // Result is NOT NULL if NOT NULL default value is provided
-          SqlTypeTransform transform;
-          if (binding.getOperandCount() < 3) {
-            transform = SqlTypeTransforms.FORCE_NULLABLE;
-          } else {
-            RelDataType defValueType = binding.getOperandType(2);
-            transform = defValueType.isNullable()
-                ? SqlTypeTransforms.FORCE_NULLABLE
-                : SqlTypeTransforms.TO_NOT_NULLABLE;
-          }
-          return transform.transformType(binding, type);
+      ReturnTypes.cascade(ReturnTypes.ARG0, (binding, type) -> {
+        // Result is NOT NULL if NOT NULL default value is provided
+        SqlTypeTransform transform;
+        if (binding.getOperandCount() < 3) {
+          transform = SqlTypeTransforms.FORCE_NULLABLE;
+        } else {
+          RelDataType defValueType = binding.getOperandType(2);
+          transform = defValueType.isNullable()
+              ? SqlTypeTransforms.FORCE_NULLABLE
+              : SqlTypeTransforms.TO_NOT_NULLABLE;
         }
+        return transform.transformType(binding, type);
       });
 
   public SqlLeadLagAggFunction(SqlKind kind) {

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/fun/SqlQuantifyOperator.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlQuantifyOperator.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlQuantifyOperator.java
index 6ee5347..bd00eff 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlQuantifyOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlQuantifyOperator.java
@@ -20,6 +20,8 @@ import org.apache.calcite.sql.SqlKind;
 
 import com.google.common.base.Preconditions;
 
+import java.util.Objects;
+
 /**
  * Definition of the SQL <code>ALL</code> and <code>SOME</code>operators.
  *
@@ -47,7 +49,7 @@ public class SqlQuantifyOperator extends SqlInOperator {
    */
   SqlQuantifyOperator(SqlKind kind, SqlKind comparisonKind) {
     super(comparisonKind.sql + " " + kind, kind);
-    this.comparisonKind = Preconditions.checkNotNull(comparisonKind);
+    this.comparisonKind = Objects.requireNonNull(comparisonKind);
     Preconditions.checkArgument(comparisonKind == SqlKind.EQUALS
         || comparisonKind == SqlKind.NOT_EQUALS
         || comparisonKind == SqlKind.LESS_THAN_OR_EQUAL

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
index 45a5536..c9f8363 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java
@@ -2242,7 +2242,7 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
       for (final SqlGroupedWindowFunction f
           : ((SqlGroupedWindowFunction) op).getAuxiliaryFunctions()) {
         builder.add(
-            Pair.<SqlNode, AuxiliaryConverter>of(copy(call, f),
+            Pair.of(copy(call, f),
                 new AuxiliaryConverter.Impl(f)));
       }
       return builder.build();
@@ -2253,7 +2253,7 @@ public class SqlStdOperatorTable extends 
ReflectiveSqlOperatorTable {
   /** Creates a copy of a call with a new operator. */
   private static SqlCall copy(SqlCall call, SqlOperator operator) {
     final List<SqlNode> list = call.getOperandList();
-    return new SqlBasicCall(operator, list.toArray(new SqlNode[list.size()]),
+    return new SqlBasicCall(operator, list.toArray(new SqlNode[0]),
         call.getParserPosition());
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java 
b/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java
index 6c38ec5..6dc7dba 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlTimestampAddFunction.java
@@ -22,7 +22,6 @@ import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.sql.SqlFunction;
 import org.apache.calcite.sql.SqlFunctionCategory;
 import org.apache.calcite.sql.SqlKind;
-import org.apache.calcite.sql.SqlOperatorBinding;
 import org.apache.calcite.sql.type.OperandTypes;
 import org.apache.calcite.sql.type.SqlReturnTypeInference;
 import org.apache.calcite.sql.type.SqlTypeFamily;
@@ -60,13 +59,11 @@ public class SqlTimestampAddFunction extends SqlFunction {
   private static final int MICROSECOND_PRECISION = 6;
 
   private static final SqlReturnTypeInference RETURN_TYPE_INFERENCE =
-      new SqlReturnTypeInference() {
-        public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
-          final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
-          return deduceType(typeFactory,
-              opBinding.getOperandLiteralValue(0, TimeUnit.class),
-              opBinding.getOperandType(1), opBinding.getOperandType(2));
-        }
+      opBinding -> {
+        final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
+        return deduceType(typeFactory,
+            opBinding.getOperandLiteralValue(0, TimeUnit.class),
+            opBinding.getOperandType(1), opBinding.getOperandType(2));
       };
 
   public static RelDataType deduceType(RelDataTypeFactory typeFactory,

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java
----------------------------------------------------------------------
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 34f10f5..0785909 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
@@ -32,12 +32,12 @@ import org.apache.calcite.util.Glossary;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 
 import java.io.Reader;
 import java.io.StringReader;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -391,7 +391,7 @@ public abstract class SqlAbstractParserImpl {
     // preserve the correct syntax (i.e. don't quote builtin function
     /// name when regenerating SQL).
     if (funName.isSimple()) {
-      final List<SqlOperator> list = Lists.newArrayList();
+      final List<SqlOperator> list = new ArrayList<>();
       opTab.lookupOperatorOverloads(funName, funcType, SqlSyntax.FUNCTION, 
list);
       if (list.size() == 1) {
         fun = list.get(0);

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java 
b/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java
index a343a39..0e3aa22 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlParser.java
@@ -26,9 +26,8 @@ import org.apache.calcite.sql.validate.SqlConformance;
 import org.apache.calcite.sql.validate.SqlConformanceEnum;
 import org.apache.calcite.sql.validate.SqlDelegatingConformance;
 
-import com.google.common.base.Preconditions;
-
 import java.io.StringReader;
+import java.util.Objects;
 
 /**
  * A <code>SqlParser</code> parses a SQL statement.
@@ -231,17 +230,17 @@ public class SqlParser {
     }
 
     public ConfigBuilder setQuotedCasing(Casing quotedCasing) {
-      this.quotedCasing = Preconditions.checkNotNull(quotedCasing);
+      this.quotedCasing = Objects.requireNonNull(quotedCasing);
       return this;
     }
 
     public ConfigBuilder setUnquotedCasing(Casing unquotedCasing) {
-      this.unquotedCasing = Preconditions.checkNotNull(unquotedCasing);
+      this.unquotedCasing = Objects.requireNonNull(unquotedCasing);
       return this;
     }
 
     public ConfigBuilder setQuoting(Quoting quoting) {
-      this.quoting = Preconditions.checkNotNull(quoting);
+      this.quoting = Objects.requireNonNull(quoting);
       return this;
     }
 
@@ -275,7 +274,7 @@ public class SqlParser {
     }
 
     public ConfigBuilder setParserFactory(SqlParserImplFactory factory) {
-      this.parserFactory = Preconditions.checkNotNull(factory);
+      this.parserFactory = Objects.requireNonNull(factory);
       return this;
     }
 
@@ -313,11 +312,11 @@ public class SqlParser {
         SqlConformance conformance, SqlParserImplFactory parserFactory) {
       this.identifierMaxLength = identifierMaxLength;
       this.caseSensitive = caseSensitive;
-      this.conformance = Preconditions.checkNotNull(conformance);
-      this.quotedCasing = Preconditions.checkNotNull(quotedCasing);
-      this.unquotedCasing = Preconditions.checkNotNull(unquotedCasing);
-      this.quoting = Preconditions.checkNotNull(quoting);
-      this.parserFactory = Preconditions.checkNotNull(parserFactory);
+      this.conformance = Objects.requireNonNull(conformance);
+      this.quotedCasing = Objects.requireNonNull(quotedCasing);
+      this.unquotedCasing = Objects.requireNonNull(unquotedCasing);
+      this.quoting = Objects.requireNonNull(quoting);
+      this.parserFactory = Objects.requireNonNull(parserFactory);
     }
 
     public int identifierMaxLength() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java 
b/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
index 80d9cc9..b744e64 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlParserPos.java
@@ -18,7 +18,6 @@ package org.apache.calcite.sql.parser;
 
 import org.apache.calcite.sql.SqlNode;
 
-import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 
@@ -46,13 +45,6 @@ public class SqlParserPos implements Serializable {
 
   private static final long serialVersionUID = 1L;
 
-  private static final Function<SqlNode, SqlParserPos> NODE_TO_POS =
-      new Function<SqlNode, SqlParserPos>() {
-        public SqlParserPos apply(SqlNode input) {
-          return input.getParserPosition();
-        }
-      };
-
   //~ Instance fields --------------------------------------------------------
 
   private final int lineNumber;
@@ -190,7 +182,7 @@ public class SqlParserPos implements Serializable {
   }
 
   private static Iterable<SqlParserPos> toPos(Iterable<SqlNode> nodes) {
-    return Iterables.transform(nodes, NODE_TO_POS);
+    return Iterables.transform(nodes, SqlNode::getParserPosition);
   }
 
   /**
@@ -198,7 +190,7 @@ public class SqlParserPos implements Serializable {
    * which spans from the beginning of the first to the end of the last.
    */
   public static SqlParserPos sum(final List<? extends SqlNode> nodes) {
-    return sum(Lists.transform(nodes, NODE_TO_POS));
+    return sum(Lists.transform(nodes, SqlNode::getParserPosition));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java 
b/core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java
index e82841a..0071c77 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlParserUtil.java
@@ -20,7 +20,6 @@ import org.apache.calcite.avatica.util.Casing;
 import org.apache.calcite.avatica.util.DateTimeUtils;
 import org.apache.calcite.rel.type.RelDataTypeSystem;
 import org.apache.calcite.runtime.CalciteContextException;
-import org.apache.calcite.runtime.PredicateImpl;
 import org.apache.calcite.sql.SqlBinaryOperator;
 import org.apache.calcite.sql.SqlDateLiteral;
 import org.apache.calcite.sql.SqlIntervalLiteral;
@@ -47,7 +46,6 @@ import org.apache.calcite.util.Util;
 import org.apache.calcite.util.trace.CalciteTrace;
 
 import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
 
 import org.slf4j.Logger;
 
@@ -60,7 +58,9 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 import java.util.Locale;
+import java.util.Objects;
 import java.util.StringTokenizer;
+import java.util.function.Predicate;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -571,11 +571,11 @@ public final class SqlParserUtil {
 
   @Deprecated // to be removed before 2.0
   public static String[] toStringArray(List<String> list) {
-    return list.toArray(new String[list.size()]);
+    return list.toArray(new String[0]);
   }
 
   public static SqlNode[] toNodeArray(List<SqlNode> list) {
-    return list.toArray(new SqlNode[list.size()]);
+    return list.toArray(new SqlNode[0]);
   }
 
   public static SqlNode[] toNodeArray(SqlNodeList list) {
@@ -608,7 +608,7 @@ public final class SqlParserUtil {
       int start,
       int end,
       T o) {
-    Preconditions.checkNotNull(list);
+    Objects.requireNonNull(list);
     Preconditions.checkArgument(start < end);
     for (int i = end - 1; i > start; --i) {
       list.remove(i);
@@ -651,21 +651,18 @@ public final class SqlParserUtil {
    */
   public static SqlNode toTreeEx(SqlSpecialOperator.TokenSequence list,
       int start, final int minPrec, final SqlKind stopperKind) {
-    final Predicate<PrecedenceClimbingParser.Token> predicate =
-        new PredicateImpl<PrecedenceClimbingParser.Token>() {
-          public boolean test(PrecedenceClimbingParser.Token t) {
-            if (t instanceof PrecedenceClimbingParser.Op) {
-              final SqlOperator op = ((ToTreeListItem) t.o).op;
-              return stopperKind != SqlKind.OTHER
-                  && op.kind == stopperKind
-                  || minPrec > 0
-                  && op.getLeftPrec() < minPrec;
-            } else {
-              return false;
-            }
+    PrecedenceClimbingParser parser = list.parser(start,
+        token -> {
+          if (token instanceof PrecedenceClimbingParser.Op) {
+            final SqlOperator op = ((ToTreeListItem) token.o).op;
+            return stopperKind != SqlKind.OTHER
+                && op.kind == stopperKind
+                || minPrec > 0
+                && op.getLeftPrec() < minPrec;
+          } else {
+            return false;
           }
-        };
-    PrecedenceClimbingParser parser = list.parser(start, predicate);
+        });
     final int beforeSize = parser.all().size();
     parser.partialParse();
     final int afterSize = parser.all().size();
@@ -814,8 +811,8 @@ public final class SqlParserUtil {
       this.list = parser.all();
     }
 
-    public PrecedenceClimbingParser parser(int start, Predicate
-        <PrecedenceClimbingParser.Token> predicate) {
+    public PrecedenceClimbingParser parser(int start,
+        Predicate<PrecedenceClimbingParser.Token> predicate) {
       return parser.copy(start, predicate);
     }
 
@@ -888,22 +885,18 @@ public final class SqlParserUtil {
                 op.getLeftPrec() < op.getRightPrec());
           } else if (op instanceof SqlSpecialOperator) {
             builder.special(item, op.getLeftPrec(), op.getRightPrec(),
-                new PrecedenceClimbingParser.Special() {
-                  public PrecedenceClimbingParser.Result apply(
-                      PrecedenceClimbingParser parser,
-                      PrecedenceClimbingParser.SpecialOp op) {
-                    final List<PrecedenceClimbingParser.Token> tokens =
-                        parser.all();
-                    final SqlSpecialOperator op1 =
-                        (SqlSpecialOperator) ((ToTreeListItem) op.o).op;
-                    SqlSpecialOperator.ReduceResult r =
-                        op1.reduceExpr(tokens.indexOf(op),
-                            new TokenSequenceImpl(parser));
-                    return new PrecedenceClimbingParser.Result(
-                        tokens.get(r.startOrdinal),
-                        tokens.get(r.endOrdinal - 1),
-                        parser.atom(r.node));
-                  }
+                (parser, op2) -> {
+                  final List<PrecedenceClimbingParser.Token> tokens =
+                      parser.all();
+                  final SqlSpecialOperator op1 =
+                      (SqlSpecialOperator) ((ToTreeListItem) op2.o).op;
+                  SqlSpecialOperator.ReduceResult r =
+                      op1.reduceExpr(tokens.indexOf(op2),
+                          new TokenSequenceImpl(parser));
+                  return new PrecedenceClimbingParser.Result(
+                      tokens.get(r.startOrdinal),
+                      tokens.get(r.endOrdinal - 1),
+                      parser.atom(r.node));
                 });
           } else {
             throw new AssertionError();
@@ -947,11 +940,7 @@ public final class SqlParserUtil {
    * thread, because {@code DateFormat} is not thread-safe. */
   private static class Format {
     private static final ThreadLocal<Format> PER_THREAD =
-        new ThreadLocal<Format>() {
-          @Override protected Format initialValue() {
-            return new Format();
-          }
-        };
+        ThreadLocal.withInitial(Format::new);
     final DateFormat timestamp =
         new SimpleDateFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING,
             Locale.ROOT);

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java 
b/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
index 4a84bb5..90ef611 100644
--- a/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
+++ b/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java
@@ -1142,7 +1142,7 @@ public class SqlPrettyWriter implements SqlWriter {
       final Set<String> names = new HashSet<>();
       names.addAll(getterMethods.keySet());
       names.addAll(setterMethods.keySet());
-      return names.toArray(new String[names.size()]);
+      return names.toArray(new String[0]);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/ArraySqlType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/type/ArraySqlType.java 
b/core/src/main/java/org/apache/calcite/sql/type/ArraySqlType.java
index c3ae782..78c3569 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/ArraySqlType.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/ArraySqlType.java
@@ -20,7 +20,7 @@ import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFamily;
 import org.apache.calcite.rel.type.RelDataTypePrecedenceList;
 
-import com.google.common.base.Preconditions;
+import java.util.Objects;
 
 /**
  * SQL array type.
@@ -38,7 +38,7 @@ public class ArraySqlType extends AbstractSqlType {
    */
   public ArraySqlType(RelDataType elementType, boolean isNullable) {
     super(SqlTypeName.ARRAY, isNullable, null);
-    this.elementType = Preconditions.checkNotNull(elementType);
+    this.elementType = Objects.requireNonNull(elementType);
     computeDigest();
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/ComparableOperandTypeChecker.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/type/ComparableOperandTypeChecker.java
 
b/core/src/main/java/org/apache/calcite/sql/type/ComparableOperandTypeChecker.java
index 0849b58..307db46 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/type/ComparableOperandTypeChecker.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/type/ComparableOperandTypeChecker.java
@@ -21,7 +21,7 @@ import org.apache.calcite.rel.type.RelDataTypeComparability;
 import org.apache.calcite.sql.SqlCallBinding;
 import org.apache.calcite.sql.SqlOperatorBinding;
 
-import com.google.common.base.Preconditions;
+import java.util.Objects;
 
 /**
  * Type checking strategy which verifies that types have the required 
attributes
@@ -45,7 +45,7 @@ public class ComparableOperandTypeChecker extends 
SameOperandTypeChecker {
       RelDataTypeComparability requiredComparability, Consistency consistency) 
{
     super(nOperands);
     this.requiredComparability = requiredComparability;
-    this.consistency = Preconditions.checkNotNull(consistency);
+    this.consistency = Objects.requireNonNull(consistency);
   }
 
   //~ Methods ----------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/CompositeOperandTypeChecker.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/type/CompositeOperandTypeChecker.java
 
b/core/src/main/java/org/apache/calcite/sql/type/CompositeOperandTypeChecker.java
index 36d47cb..7c55750 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/type/CompositeOperandTypeChecker.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/type/CompositeOperandTypeChecker.java
@@ -22,11 +22,11 @@ import org.apache.calcite.sql.SqlOperandCountRange;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 import java.util.AbstractList;
 import java.util.List;
+import java.util.Objects;
 import javax.annotation.Nullable;
 
 /**
@@ -93,8 +93,8 @@ public class CompositeOperandTypeChecker implements 
SqlOperandTypeChecker {
       ImmutableList<? extends SqlOperandTypeChecker> allowedRules,
       @Nullable String allowedSignatures,
       @Nullable SqlOperandCountRange range) {
-    this.allowedRules = Preconditions.checkNotNull(allowedRules);
-    this.composition = Preconditions.checkNotNull(composition);
+    this.allowedRules = Objects.requireNonNull(allowedRules);
+    this.composition = Objects.requireNonNull(composition);
     this.allowedSignatures = allowedSignatures;
     this.range = range;
     assert (range != null) == (composition == Composition.REPEAT);

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java 
b/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java
index b9cf248..455ec41 100644
--- 
a/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java
+++ 
b/core/src/main/java/org/apache/calcite/sql/type/FamilyOperandTypeChecker.java
@@ -24,10 +24,10 @@ import org.apache.calcite.sql.SqlOperandCountRange;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.sql.SqlUtil;
 
-import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
+import java.util.function.Predicate;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -55,7 +55,7 @@ public class FamilyOperandTypeChecker implements 
SqlSingleOperandTypeChecker {
   //~ Methods ----------------------------------------------------------------
 
   public boolean isOptional(int i) {
-    return optional.apply(i);
+    return optional.test(i);
   }
 
   public boolean checkSingleOperandType(
@@ -120,7 +120,7 @@ public class FamilyOperandTypeChecker implements 
SqlSingleOperandTypeChecker {
   public SqlOperandCountRange getOperandCountRange() {
     final int max = families.size();
     int min = max;
-    while (min > 0 && optional.apply(min - 1)) {
+    while (min > 0 && optional.test(min - 1)) {
       --min;
     }
     return SqlOperandCountRanges.between(min, max);

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/InferTypes.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/type/InferTypes.java 
b/core/src/main/java/org/apache/calcite/sql/type/InferTypes.java
index 938a058..10dd95c 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/InferTypes.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/InferTypes.java
@@ -18,7 +18,6 @@ package org.apache.calcite.sql.type;
 
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
-import org.apache.calcite.sql.SqlCallBinding;
 import org.apache.calcite.sql.SqlNode;
 
 import com.google.common.collect.ImmutableList;
@@ -39,30 +38,25 @@ public abstract class InferTypes {
    * from the first operand with a known type.
    */
   public static final SqlOperandTypeInference FIRST_KNOWN =
-      new SqlOperandTypeInference() {
-        public void inferOperandTypes(
-            SqlCallBinding callBinding,
-            RelDataType returnType,
-            RelDataType[] operandTypes) {
-          final RelDataType unknownType =
-              callBinding.getValidator().getUnknownType();
-          RelDataType knownType = unknownType;
-          for (SqlNode operand : callBinding.operands()) {
-            knownType = callBinding.getValidator().deriveType(
-                callBinding.getScope(), operand);
-            if (!knownType.equals(unknownType)) {
-              break;
-            }
+      (callBinding, returnType, operandTypes) -> {
+        final RelDataType unknownType =
+            callBinding.getValidator().getUnknownType();
+        RelDataType knownType = unknownType;
+        for (SqlNode operand : callBinding.operands()) {
+          knownType = callBinding.getValidator().deriveType(
+              callBinding.getScope(), operand);
+          if (!knownType.equals(unknownType)) {
+            break;
           }
+        }
 
-          // REVIEW jvs 11-Nov-2008:  We can't assert this
-          // because SqlAdvisorValidator produces
-          // unknown types for incomplete expressions.
-          // Maybe we need to distinguish the two kinds of unknown.
-          //assert !knownType.equals(unknownType);
-          for (int i = 0; i < operandTypes.length; ++i) {
-            operandTypes[i] = knownType;
-          }
+        // REVIEW jvs 11-Nov-2008:  We can't assert this
+        // because SqlAdvisorValidator produces
+        // unknown types for incomplete expressions.
+        // Maybe we need to distinguish the two kinds of unknown.
+        //assert !knownType.equals(unknownType);
+        for (int i = 0; i < operandTypes.length; ++i) {
+          operandTypes[i] = knownType;
         }
       };
 
@@ -72,17 +66,12 @@ public abstract class InferTypes {
    * the same number of fields as the number of operands.
    */
   public static final SqlOperandTypeInference RETURN_TYPE =
-      new SqlOperandTypeInference() {
-        public void inferOperandTypes(
-            SqlCallBinding callBinding,
-            RelDataType returnType,
-            RelDataType[] operandTypes) {
-          for (int i = 0; i < operandTypes.length; ++i) {
-            operandTypes[i] =
-                returnType.isStruct()
-                    ? returnType.getFieldList().get(i).getType()
-                    : returnType;
-          }
+      (callBinding, returnType, operandTypes) -> {
+        for (int i = 0; i < operandTypes.length; ++i) {
+          operandTypes[i] =
+              returnType.isStruct()
+                  ? returnType.getFieldList().get(i).getType()
+                  : returnType;
         }
       };
 
@@ -91,16 +80,11 @@ public abstract class InferTypes {
    * to be boolean.
    */
   public static final SqlOperandTypeInference BOOLEAN =
-      new SqlOperandTypeInference() {
-        public void inferOperandTypes(
-            SqlCallBinding callBinding,
-            RelDataType returnType,
-            RelDataType[] operandTypes) {
-          RelDataTypeFactory typeFactory = callBinding.getTypeFactory();
-          for (int i = 0; i < operandTypes.length; ++i) {
-            operandTypes[i] =
-                typeFactory.createSqlType(SqlTypeName.BOOLEAN);
-          }
+      (callBinding, returnType, operandTypes) -> {
+        RelDataTypeFactory typeFactory = callBinding.getTypeFactory();
+        for (int i = 0; i < operandTypes.length; ++i) {
+          operandTypes[i] =
+              typeFactory.createSqlType(SqlTypeName.BOOLEAN);
         }
       };
 
@@ -112,16 +96,11 @@ public abstract class InferTypes {
    * use something that every other type can be cast to.
    */
   public static final SqlOperandTypeInference VARCHAR_1024 =
-      new SqlOperandTypeInference() {
-        public void inferOperandTypes(
-            SqlCallBinding callBinding,
-            RelDataType returnType,
-            RelDataType[] operandTypes) {
-          RelDataTypeFactory typeFactory = callBinding.getTypeFactory();
-          for (int i = 0; i < operandTypes.length; ++i) {
-            operandTypes[i] =
-                typeFactory.createSqlType(SqlTypeName.VARCHAR, 1024);
-          }
+      (callBinding, returnType, operandTypes) -> {
+        RelDataTypeFactory typeFactory = callBinding.getTypeFactory();
+        for (int i = 0; i < operandTypes.length; ++i) {
+          operandTypes[i] =
+              typeFactory.createSqlType(SqlTypeName.VARCHAR, 1024);
         }
       };
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java 
b/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
index 4789c06..399709e 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/IntervalSqlType.java
@@ -27,7 +27,7 @@ import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.pretty.SqlPrettyWriter;
 import org.apache.calcite.sql.util.SqlString;
 
-import com.google.common.base.Preconditions;
+import java.util.Objects;
 
 /**
  * IntervalSqlType represents a standard SQL datetime interval type.
@@ -48,8 +48,8 @@ public class IntervalSqlType extends AbstractSqlType {
       SqlIntervalQualifier intervalQualifier,
       boolean isNullable) {
     super(intervalQualifier.typeName(), isNullable, null);
-    this.typeSystem = Preconditions.checkNotNull(typeSystem);
-    this.intervalQualifier = Preconditions.checkNotNull(intervalQualifier);
+    this.typeSystem = Objects.requireNonNull(typeSystem);
+    this.intervalQualifier = Objects.requireNonNull(intervalQualifier);
     computeDigest();
   }
 
@@ -84,10 +84,10 @@ public class IntervalSqlType extends AbstractSqlType {
       IntervalSqlType that) {
     assert this.typeName.isYearMonth() == that.typeName.isYearMonth();
     boolean nullable = isNullable || that.isNullable;
-    TimeUnit thisStart = Preconditions.checkNotNull(typeName.getStartUnit());
+    TimeUnit thisStart = Objects.requireNonNull(typeName.getStartUnit());
     TimeUnit thisEnd = typeName.getEndUnit();
     final TimeUnit thatStart =
-        Preconditions.checkNotNull(that.typeName.getStartUnit());
+        Objects.requireNonNull(that.typeName.getStartUnit());
     final TimeUnit thatEnd = that.typeName.getEndUnit();
 
     int secondPrec =

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java 
b/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java
index c619bb1..dcdaa63 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java
@@ -18,7 +18,6 @@ package org.apache.calcite.sql.type;
 
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeComparability;
-import org.apache.calcite.runtime.PredicateImpl;
 import org.apache.calcite.sql.SqlCallBinding;
 import org.apache.calcite.sql.SqlLiteral;
 import org.apache.calcite.sql.SqlNode;
@@ -26,12 +25,11 @@ import org.apache.calcite.sql.SqlOperandCountRange;
 import org.apache.calcite.sql.SqlOperator;
 import org.apache.calcite.sql.SqlUtil;
 
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.function.Predicate;
 
 import static org.apache.calcite.util.Static.RESOURCE;
 
@@ -62,7 +60,7 @@ public abstract class OperandTypes {
    */
   public static FamilyOperandTypeChecker family(SqlTypeFamily... families) {
     return new FamilyOperandTypeChecker(ImmutableList.copyOf(families),
-        Predicates.<Integer>alwaysFalse());
+        i -> false);
   }
 
   /**
@@ -79,7 +77,7 @@ public abstract class OperandTypes {
    * corresponding family.
    */
   public static FamilyOperandTypeChecker family(List<SqlTypeFamily> families) {
-    return family(families, Predicates.<Integer>alwaysFalse());
+    return family(families, i -> false);
   }
 
   /**
@@ -205,11 +203,7 @@ public abstract class OperandTypes {
   public static final SqlSingleOperandTypeChecker NUMERIC_OPTIONAL_INTEGER =
       family(ImmutableList.of(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER),
           // Second operand optional (operand index 0, 1)
-          new PredicateImpl<Integer>() {
-            public boolean test(Integer number) {
-              return number == 1;
-            }
-          });
+          number -> number == 1);
 
   public static final SqlSingleOperandTypeChecker NUMERIC_INTEGER =
       family(SqlTypeFamily.NUMERIC, SqlTypeFamily.INTEGER);
@@ -288,7 +282,7 @@ public abstract class OperandTypes {
    */
   public static final SqlSingleOperandTypeChecker POSITIVE_INTEGER_LITERAL =
       new FamilyOperandTypeChecker(ImmutableList.of(SqlTypeFamily.INTEGER),
-          Predicates.<Integer>alwaysFalse()) {
+          i -> false) {
         public boolean checkSingleOperandType(
             SqlCallBinding callBinding,
             SqlNode node,
@@ -484,7 +478,7 @@ public abstract class OperandTypes {
       new FamilyOperandTypeChecker(
           ImmutableList.of(SqlTypeFamily.DATETIME, SqlTypeFamily.DATETIME,
               SqlTypeFamily.DATETIME_INTERVAL),
-          Predicates.<Integer>alwaysFalse()) {
+          i -> false) {
         public boolean checkOperandTypes(
             SqlCallBinding callBinding,
             boolean throwOnFailure) {

Reply via email to