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 2018/07/09 07:49:33 UTC

[11/30] calcite git commit: [CALCITE-2259] Allow Java 8 syntax

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java b/core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java
index 801caa9..862b26e 100644
--- a/core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java
+++ b/core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java
@@ -25,20 +25,15 @@ import org.apache.calcite.avatica.remote.Service;
 import org.apache.calcite.avatica.server.AvaticaJsonHandler;
 import org.apache.calcite.avatica.server.HttpServer;
 import org.apache.calcite.avatica.server.Main;
-import org.apache.calcite.avatica.server.Main.HandlerFactory;
 import org.apache.calcite.prepare.CalcitePrepareImpl;
 import org.apache.calcite.test.CalciteAssert;
 import org.apache.calcite.test.JdbcFrontLinqBackTest;
 import org.apache.calcite.test.JdbcTest;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 
 import org.hamcrest.CoreMatchers;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -71,9 +66,11 @@ import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.function.Function;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
@@ -100,53 +97,47 @@ public class CalciteRemoteDriverTest {
       };
 
   private static final Function<Connection, ResultSet> GET_SCHEMAS =
-      new Function<Connection, ResultSet>() {
-        public ResultSet apply(Connection input) {
-          try {
-            return input.getMetaData().getSchemas();
-          } catch (SQLException e) {
-            throw new RuntimeException(e);
-          }
+      connection -> {
+        try {
+          return connection.getMetaData().getSchemas();
+        } catch (SQLException e) {
+          throw new RuntimeException(e);
         }
       };
+
   private static final Function<Connection, ResultSet> GET_CATALOGS =
-      new Function<Connection, ResultSet>() {
-        public ResultSet apply(Connection input) {
-          try {
-            return input.getMetaData().getCatalogs();
-          } catch (SQLException e) {
-            throw new RuntimeException(e);
-          }
+      connection -> {
+        try {
+          return connection.getMetaData().getCatalogs();
+        } catch (SQLException e) {
+          throw new RuntimeException(e);
         }
       };
+
   private static final Function<Connection, ResultSet> GET_COLUMNS =
-      new Function<Connection, ResultSet>() {
-        public ResultSet apply(Connection input) {
-          try {
-            return input.getMetaData().getColumns(null, null, null, null);
-          } catch (SQLException e) {
-            throw new RuntimeException(e);
-          }
+      connection -> {
+        try {
+          return connection.getMetaData().getColumns(null, null, null, null);
+        } catch (SQLException e) {
+          throw new RuntimeException(e);
         }
       };
+
   private static final Function<Connection, ResultSet> GET_TYPEINFO =
-      new Function<Connection, ResultSet>() {
-        public ResultSet apply(Connection input) {
-          try {
-            return input.getMetaData().getTypeInfo();
-          } catch (SQLException e) {
-            throw new RuntimeException(e);
-          }
+      connection -> {
+        try {
+          return connection.getMetaData().getTypeInfo();
+        } catch (SQLException e) {
+          throw new RuntimeException(e);
         }
       };
+
   private static final Function<Connection, ResultSet> GET_TABLE_TYPES =
-      new Function<Connection, ResultSet>() {
-        public ResultSet apply(Connection input) {
-          try {
-            return input.getMetaData().getTableTypes();
-          } catch (SQLException e) {
-            throw new RuntimeException(e);
-          }
+      connection -> {
+        try {
+          return connection.getMetaData().getTableTypes();
+        } catch (SQLException e) {
+          throw new RuntimeException(e);
         }
       };
 
@@ -157,11 +148,8 @@ public class CalciteRemoteDriverTest {
     localConnection = CalciteAssert.hr().connect();
 
     // Make sure we pick an ephemeral port for the server
-    start = Main.start(new String[]{Factory.class.getName()}, 0, new HandlerFactory() {
-      public AvaticaJsonHandler createHandler(Service service) {
-        return new AvaticaJsonHandler(service);
-      }
-    });
+    start = Main.start(new String[]{Factory.class.getName()}, 0,
+        AvaticaJsonHandler::new);
   }
 
   protected static Connection getRemoteConnection() throws SQLException {
@@ -311,7 +299,7 @@ public class CalciteRemoteDriverTest {
    * variables. */
   @Test public void testParameterConvert() throws Exception {
     final StringBuilder sql = new StringBuilder("select 1");
-    final Map<SqlType, Integer> map = Maps.newHashMap();
+    final Map<SqlType, Integer> map = new HashMap<>();
     for (Map.Entry<Class, SqlType> entry : SqlType.getSetConversions()) {
       final SqlType sqlType = entry.getValue();
       switch (sqlType) {
@@ -629,7 +617,7 @@ public class CalciteRemoteDriverTest {
 
   /** A bunch of sample values of various types. */
   private static final List<Object> SAMPLE_VALUES =
-      ImmutableList.<Object>of(false, true,
+      ImmutableList.of(false, true,
           // byte
           (byte) 0, (byte) 1, Byte.MIN_VALUE, Byte.MAX_VALUE,
           // short
@@ -664,7 +652,7 @@ public class CalciteRemoteDriverTest {
           new byte[0], "hello".getBytes(StandardCharsets.UTF_8));
 
   private static List<Object> values(Class clazz) {
-    final List<Object> list = Lists.newArrayList();
+    final List<Object> list = new ArrayList<>();
     for (Object sampleValue : SAMPLE_VALUES) {
       if (sampleValue.getClass() == clazz) {
         list.add(sampleValue);

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java b/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
index 03bd725..2d2d67b 100644
--- a/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/RelOptUtilTest.java
@@ -39,6 +39,7 @@ import com.google.common.collect.Lists;
 
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -189,9 +190,9 @@ public class RelOptUtilTest {
 
   private static void splitJoinConditionHelper(RexNode joinCond, List<Integer> expLeftKeys,
       List<Integer> expRightKeys, List<Boolean> expFilterNulls, RexNode expRemaining) {
-    List<Integer> actLeftKeys = Lists.newArrayList();
-    List<Integer> actRightKeys = Lists.newArrayList();
-    List<Boolean> actFilterNulls = Lists.newArrayList();
+    List<Integer> actLeftKeys = new ArrayList<>();
+    List<Integer> actRightKeys = new ArrayList<>();
+    List<Boolean> actFilterNulls = new ArrayList<>();
 
     RexNode actRemaining = RelOptUtil.splitJoinCondition(EMP_SCAN, DEPT_SCAN, joinCond, actLeftKeys,
         actRightKeys, actFilterNulls);

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java b/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
index 2ceea23..c411888 100644
--- a/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/RelWriterTest.java
@@ -116,41 +116,37 @@ public class RelWriterTest {
    */
   @Test public void testWriter() {
     String s =
-        Frameworks.withPlanner(
-            new Frameworks.PlannerAction<String>() {
-              public String apply(RelOptCluster cluster,
-                  RelOptSchema relOptSchema, SchemaPlus rootSchema) {
-                rootSchema.add("hr",
-                    new ReflectiveSchema(new JdbcTest.HrSchema()));
-                LogicalTableScan scan =
-                    LogicalTableScan.create(cluster,
-                        relOptSchema.getTableForMember(
-                            Arrays.asList("hr", "emps")));
-                final RexBuilder rexBuilder = cluster.getRexBuilder();
-                LogicalFilter filter =
-                    LogicalFilter.create(scan,
-                        rexBuilder.makeCall(
-                            SqlStdOperatorTable.EQUALS,
-                            rexBuilder.makeFieldAccess(
-                                rexBuilder.makeRangeReference(scan),
-                                "deptno", true),
-                            rexBuilder.makeExactLiteral(BigDecimal.TEN)));
-                final RelJsonWriter writer = new RelJsonWriter();
-                final RelDataType bigIntType =
-                    cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT);
-                LogicalAggregate aggregate =
-                    LogicalAggregate.create(filter, ImmutableBitSet.of(0), null,
-                        ImmutableList.of(
-                            AggregateCall.create(SqlStdOperatorTable.COUNT,
-                                true, false, ImmutableList.of(1), -1,
-                                bigIntType, "c"),
-                            AggregateCall.create(SqlStdOperatorTable.COUNT,
-                                false, false, ImmutableList.<Integer>of(), -1,
-                                bigIntType, "d")));
-                aggregate.explain(writer);
-                return writer.asString();
-              }
-            });
+        Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> {
+          rootSchema.add("hr",
+              new ReflectiveSchema(new JdbcTest.HrSchema()));
+          LogicalTableScan scan =
+              LogicalTableScan.create(cluster,
+                  relOptSchema.getTableForMember(
+                      Arrays.asList("hr", "emps")));
+          final RexBuilder rexBuilder = cluster.getRexBuilder();
+          LogicalFilter filter =
+              LogicalFilter.create(scan,
+                  rexBuilder.makeCall(
+                      SqlStdOperatorTable.EQUALS,
+                      rexBuilder.makeFieldAccess(
+                          rexBuilder.makeRangeReference(scan),
+                          "deptno", true),
+                      rexBuilder.makeExactLiteral(BigDecimal.TEN)));
+          final RelJsonWriter writer = new RelJsonWriter();
+          final RelDataType bigIntType =
+              cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT);
+          LogicalAggregate aggregate =
+              LogicalAggregate.create(filter, ImmutableBitSet.of(0), null,
+                  ImmutableList.of(
+                      AggregateCall.create(SqlStdOperatorTable.COUNT,
+                          true, false, ImmutableList.of(1), -1,
+                          bigIntType, "c"),
+                      AggregateCall.create(SqlStdOperatorTable.COUNT,
+                          false, false, ImmutableList.of(), -1,
+                          bigIntType, "d")));
+          aggregate.explain(writer);
+          return writer.asString();
+        });
     assertThat(s, is(XX));
   }
 
@@ -159,25 +155,21 @@ public class RelWriterTest {
    */
   @Test public void testReader() {
     String s =
-        Frameworks.withPlanner(
-            new Frameworks.PlannerAction<String>() {
-              public String apply(RelOptCluster cluster,
-                  RelOptSchema relOptSchema, SchemaPlus rootSchema) {
-                SchemaPlus schema =
-                    rootSchema.add("hr",
-                        new ReflectiveSchema(new JdbcTest.HrSchema()));
-                final RelJsonReader reader =
-                    new RelJsonReader(cluster, relOptSchema, schema);
-                RelNode node;
-                try {
-                  node = reader.read(XX);
-                } catch (IOException e) {
-                  throw new RuntimeException(e);
-                }
-                return RelOptUtil.dumpPlan("", node, SqlExplainFormat.TEXT,
-                    SqlExplainLevel.EXPPLAN_ATTRIBUTES);
-              }
-            });
+        Frameworks.withPlanner((cluster, relOptSchema, rootSchema) -> {
+          SchemaPlus schema =
+              rootSchema.add("hr",
+                  new ReflectiveSchema(new JdbcTest.HrSchema()));
+          final RelJsonReader reader =
+              new RelJsonReader(cluster, relOptSchema, schema);
+          RelNode node;
+          try {
+            node = reader.read(XX);
+          } catch (IOException e) {
+            throw new RuntimeException(e);
+          }
+          return RelOptUtil.dumpPlan("", node, SqlExplainFormat.TEXT,
+              SqlExplainLevel.EXPPLAN_ATTRIBUTES);
+        });
 
     assertThat(s,
         isLinux("LogicalAggregate(group=[{0}], agg#0=[COUNT(DISTINCT $1)], agg#1=[COUNT()])\n"

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/plan/volcano/ComboRuleTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/plan/volcano/ComboRuleTest.java b/core/src/test/java/org/apache/calcite/plan/volcano/ComboRuleTest.java
index 3cd8195..e8dc2c9 100644
--- a/core/src/test/java/org/apache/calcite/plan/volcano/ComboRuleTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/volcano/ComboRuleTest.java
@@ -45,7 +45,6 @@ import static org.apache.calcite.plan.volcano.PlannerTests.newCluster;
 
 import static org.junit.Assert.assertTrue;
 
-
 /**
  * Unit test for {@link VolcanoPlanner}
  */

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/plan/volcano/TraitConversionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/plan/volcano/TraitConversionTest.java b/core/src/test/java/org/apache/calcite/plan/volcano/TraitConversionTest.java
index b3ae329..2396f53 100644
--- a/core/src/test/java/org/apache/calcite/plan/volcano/TraitConversionTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/volcano/TraitConversionTest.java
@@ -41,7 +41,6 @@ import static org.apache.calcite.plan.volcano.PlannerTests.newCluster;
 
 import static org.junit.Assert.assertTrue;
 
-
 /**
  * Unit test for {@link org.apache.calcite.rel.RelDistributionTraitDef}.
  */

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/plan/volcano/TraitPropagationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/plan/volcano/TraitPropagationTest.java b/core/src/test/java/org/apache/calcite/plan/volcano/TraitPropagationTest.java
index 8847f93..2822c1c 100644
--- a/core/src/test/java/org/apache/calcite/plan/volcano/TraitPropagationTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/volcano/TraitPropagationTest.java
@@ -71,7 +71,6 @@ import org.apache.calcite.tools.RuleSet;
 import org.apache.calcite.tools.RuleSets;
 import org.apache.calcite.util.ImmutableBitSet;
 
-import com.google.common.base.Supplier;
 import com.google.common.collect.ImmutableList;
 
 import org.junit.Test;
@@ -140,7 +139,7 @@ public class TraitPropagationTest {
         }
 
         @Override public Statistic getStatistic() {
-          return Statistics.of(100d, ImmutableList.<ImmutableBitSet>of(),
+          return Statistics.of(100d, ImmutableList.of(),
               ImmutableList.of(COLLATION));
         }
       };
@@ -329,11 +328,7 @@ public class TraitPropagationTest {
           cluster.traitSet().replace(PHYSICAL)
               .replaceIfs(
                   RelCollationTraitDef.INSTANCE,
-                  new Supplier<List<RelCollation>>() {
-                    public List<RelCollation> get() {
-                      return RelMdCollation.project(mq, input, projects);
-                    }
-                  });
+                  () -> RelMdCollation.project(mq, input, projects));
       return new PhysProj(cluster, traitSet, input, projects, rowType);
     }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/prepare/LookupOperatorOverloadsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/prepare/LookupOperatorOverloadsTest.java b/core/src/test/java/org/apache/calcite/prepare/LookupOperatorOverloadsTest.java
index f36372b..69a4c1d 100644
--- a/core/src/test/java/org/apache/calcite/prepare/LookupOperatorOverloadsTest.java
+++ b/core/src/test/java/org/apache/calcite/prepare/LookupOperatorOverloadsTest.java
@@ -144,7 +144,7 @@ public class LookupOperatorOverloadsTest {
       final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
       CalciteCatalogReader reader =
           new CalciteCatalogReader(prepareContext.getRootSchema(),
-              ImmutableList.<String>of(), typeFactory, prepareContext.config());
+              ImmutableList.of(), typeFactory, prepareContext.config());
 
       final List<SqlOperator> operatorList = new ArrayList<>();
       SqlIdentifier myFuncIdentifier =

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/profile/ProfilerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/profile/ProfilerTest.java b/core/src/test/java/org/apache/calcite/profile/ProfilerTest.java
index 9e8de90..c31187a 100644
--- a/core/src/test/java/org/apache/calcite/profile/ProfilerTest.java
+++ b/core/src/test/java/org/apache/calcite/profile/ProfilerTest.java
@@ -16,27 +16,18 @@
  */
 package org.apache.calcite.profile;
 
-import org.apache.calcite.jdbc.CalciteConnection;
 import org.apache.calcite.linq4j.AbstractEnumerable;
 import org.apache.calcite.linq4j.Enumerable;
 import org.apache.calcite.linq4j.Enumerator;
 import org.apache.calcite.rel.metadata.NullSentinel;
-import org.apache.calcite.runtime.PredicateImpl;
 import org.apache.calcite.test.CalciteAssert;
 import org.apache.calcite.test.Matchers;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.calcite.util.JsonBuilder;
-import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 
-import com.google.common.base.Function;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Ordering;
 
@@ -53,8 +44,12 @@ import java.util.Collection;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.SortedSet;
 import java.util.TreeSet;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -114,84 +109,82 @@ public class ProfilerTest {
     final String sql = "select * from \"scott\".emp\n"
         + "join \"scott\".dept on emp.deptno = dept.deptno";
     sql(sql)
-        .where(new PredicateImpl<Profiler.Statistic>() {
-          public boolean test(Profiler.Statistic statistic) {
-            return !(statistic instanceof Profiler.Distribution)
+        .where(statistic ->
+            !(statistic instanceof Profiler.Distribution)
                 || ((Profiler.Distribution) statistic).cardinality < 14
-                && ((Profiler.Distribution) statistic).minimal;
-          }
-        }).unordered(
-        "{type:distribution,columns:[COMM,DEPTNO0],cardinality:5.0}",
-        "{type:distribution,columns:[COMM,DEPTNO],cardinality:5.0}",
-        "{type:distribution,columns:[COMM,DNAME],cardinality:5.0}",
-        "{type:distribution,columns:[COMM,LOC],cardinality:5.0}",
-        "{type:distribution,columns:[COMM],values:[0.00,300.00,500.00,1400.00],cardinality:5.0,nullCount:10}",
-        "{type:distribution,columns:[DEPTNO,DEPTNO0],cardinality:3.0}",
-        "{type:distribution,columns:[DEPTNO,DNAME],cardinality:3.0}",
-        "{type:distribution,columns:[DEPTNO,LOC],cardinality:3.0}",
-        "{type:distribution,columns:[DEPTNO0,DNAME],cardinality:3.0}",
-        "{type:distribution,columns:[DEPTNO0,LOC],cardinality:3.0}",
-        "{type:distribution,columns:[DEPTNO0],values:[10,20,30],cardinality:3.0}",
-        "{type:distribution,columns:[DEPTNO],values:[10,20,30],cardinality:3.0}",
-        "{type:distribution,columns:[DNAME,LOC],cardinality:3.0}",
-        "{type:distribution,columns:[DNAME],values:[ACCOUNTING,RESEARCH,SALES],cardinality:3.0}",
-        "{type:distribution,columns:[HIREDATE,COMM],cardinality:5.0}",
-        "{type:distribution,columns:[HIREDATE],values:[1980-12-17,1981-01-05,1981-02-04,1981-02-20,1981-02-22,1981-06-09,1981-09-08,1981-09-28,1981-11-17,1981-12-03,1982-01-23,1987-04-19,1987-05-23],cardinality:13.0}",
-        "{type:distribution,columns:[JOB,COMM],cardinality:5.0}",
-        "{type:distribution,columns:[JOB,DEPTNO0],cardinality:9.0}",
-        "{type:distribution,columns:[JOB,DEPTNO],cardinality:9.0}",
-        "{type:distribution,columns:[JOB,DNAME],cardinality:9.0}",
-        "{type:distribution,columns:[JOB,LOC],cardinality:9.0}",
-        "{type:distribution,columns:[JOB,MGR,DEPTNO0],cardinality:10.0}",
-        "{type:distribution,columns:[JOB,MGR,DEPTNO],cardinality:10.0}",
-        "{type:distribution,columns:[JOB,MGR,DNAME],cardinality:10.0}",
-        "{type:distribution,columns:[JOB,MGR,LOC],cardinality:10.0}",
-        "{type:distribution,columns:[JOB,MGR],cardinality:8.0}",
-        "{type:distribution,columns:[JOB,SAL],cardinality:12.0}",
-        "{type:distribution,columns:[JOB],values:[ANALYST,CLERK,MANAGER,PRESIDENT,SALESMAN],cardinality:5.0}",
-        "{type:distribution,columns:[LOC],values:[CHICAGO,DALLAS,NEWYORK],cardinality:3.0}",
-        "{type:distribution,columns:[MGR,COMM],cardinality:5.0}",
-        "{type:distribution,columns:[MGR,DEPTNO0],cardinality:9.0}",
-        "{type:distribution,columns:[MGR,DEPTNO],cardinality:9.0}",
-        "{type:distribution,columns:[MGR,DNAME],cardinality:9.0}",
-        "{type:distribution,columns:[MGR,LOC],cardinality:9.0}",
-        "{type:distribution,columns:[MGR,SAL],cardinality:12.0}",
-        "{type:distribution,columns:[MGR],values:[7566,7698,7782,7788,7839,7902],cardinality:7.0,nullCount:1}",
-        "{type:distribution,columns:[SAL,COMM],cardinality:5.0}",
-        "{type:distribution,columns:[SAL,DEPTNO0],cardinality:12.0}",
-        "{type:distribution,columns:[SAL,DEPTNO],cardinality:12.0}",
-        "{type:distribution,columns:[SAL,DNAME],cardinality:12.0}",
-        "{type:distribution,columns:[SAL,LOC],cardinality:12.0}",
-        "{type:distribution,columns:[SAL],values:[800.00,950.00,1100.00,1250.00,1300.00,1500.00,1600.00,2450.00,2850.00,2975.00,3000.00,5000.00],cardinality:12.0}",
-        "{type:distribution,columns:[],cardinality:1.0}",
-        "{type:fd,columns:[DEPTNO0],dependentColumn:DEPTNO}",
-        "{type:fd,columns:[DEPTNO0],dependentColumn:DNAME}",
-        "{type:fd,columns:[DEPTNO0],dependentColumn:LOC}",
-        "{type:fd,columns:[DEPTNO],dependentColumn:DEPTNO0}",
-        "{type:fd,columns:[DEPTNO],dependentColumn:DNAME}",
-        "{type:fd,columns:[DEPTNO],dependentColumn:LOC}",
-        "{type:fd,columns:[DNAME],dependentColumn:DEPTNO0}",
-        "{type:fd,columns:[DNAME],dependentColumn:DEPTNO}",
-        "{type:fd,columns:[DNAME],dependentColumn:LOC}",
-        "{type:fd,columns:[JOB],dependentColumn:COMM}",
-        "{type:fd,columns:[LOC],dependentColumn:DEPTNO0}",
-        "{type:fd,columns:[LOC],dependentColumn:DEPTNO}",
-        "{type:fd,columns:[LOC],dependentColumn:DNAME}",
-        "{type:fd,columns:[SAL],dependentColumn:DEPTNO0}",
-        "{type:fd,columns:[SAL],dependentColumn:DEPTNO}",
-        "{type:fd,columns:[SAL],dependentColumn:DNAME}",
-        "{type:fd,columns:[SAL],dependentColumn:JOB}",
-        "{type:fd,columns:[SAL],dependentColumn:LOC}",
-        "{type:fd,columns:[SAL],dependentColumn:MGR}",
-        "{type:rowCount,rowCount:14}",
-        "{type:unique,columns:[EMPNO]}",
-        "{type:unique,columns:[ENAME]}",
-        "{type:unique,columns:[HIREDATE,DEPTNO0]}",
-        "{type:unique,columns:[HIREDATE,DEPTNO]}",
-        "{type:unique,columns:[HIREDATE,DNAME]}",
-        "{type:unique,columns:[HIREDATE,LOC]}",
-        "{type:unique,columns:[HIREDATE,SAL]}",
-        "{type:unique,columns:[JOB,HIREDATE]}");
+                && ((Profiler.Distribution) statistic).minimal)
+        .unordered(
+            "{type:distribution,columns:[COMM,DEPTNO0],cardinality:5.0}",
+            "{type:distribution,columns:[COMM,DEPTNO],cardinality:5.0}",
+            "{type:distribution,columns:[COMM,DNAME],cardinality:5.0}",
+            "{type:distribution,columns:[COMM,LOC],cardinality:5.0}",
+            "{type:distribution,columns:[COMM],values:[0.00,300.00,500.00,1400.00],cardinality:5.0,nullCount:10}",
+            "{type:distribution,columns:[DEPTNO,DEPTNO0],cardinality:3.0}",
+            "{type:distribution,columns:[DEPTNO,DNAME],cardinality:3.0}",
+            "{type:distribution,columns:[DEPTNO,LOC],cardinality:3.0}",
+            "{type:distribution,columns:[DEPTNO0,DNAME],cardinality:3.0}",
+            "{type:distribution,columns:[DEPTNO0,LOC],cardinality:3.0}",
+            "{type:distribution,columns:[DEPTNO0],values:[10,20,30],cardinality:3.0}",
+            "{type:distribution,columns:[DEPTNO],values:[10,20,30],cardinality:3.0}",
+            "{type:distribution,columns:[DNAME,LOC],cardinality:3.0}",
+            "{type:distribution,columns:[DNAME],values:[ACCOUNTING,RESEARCH,SALES],cardinality:3.0}",
+            "{type:distribution,columns:[HIREDATE,COMM],cardinality:5.0}",
+            "{type:distribution,columns:[HIREDATE],values:[1980-12-17,1981-01-05,1981-02-04,1981-02-20,1981-02-22,1981-06-09,1981-09-08,1981-09-28,1981-11-17,1981-12-03,1982-01-23,1987-04-19,1987-05-23],cardinality:13.0}",
+            "{type:distribution,columns:[JOB,COMM],cardinality:5.0}",
+            "{type:distribution,columns:[JOB,DEPTNO0],cardinality:9.0}",
+            "{type:distribution,columns:[JOB,DEPTNO],cardinality:9.0}",
+            "{type:distribution,columns:[JOB,DNAME],cardinality:9.0}",
+            "{type:distribution,columns:[JOB,LOC],cardinality:9.0}",
+            "{type:distribution,columns:[JOB,MGR,DEPTNO0],cardinality:10.0}",
+            "{type:distribution,columns:[JOB,MGR,DEPTNO],cardinality:10.0}",
+            "{type:distribution,columns:[JOB,MGR,DNAME],cardinality:10.0}",
+            "{type:distribution,columns:[JOB,MGR,LOC],cardinality:10.0}",
+            "{type:distribution,columns:[JOB,MGR],cardinality:8.0}",
+            "{type:distribution,columns:[JOB,SAL],cardinality:12.0}",
+            "{type:distribution,columns:[JOB],values:[ANALYST,CLERK,MANAGER,PRESIDENT,SALESMAN],cardinality:5.0}",
+            "{type:distribution,columns:[LOC],values:[CHICAGO,DALLAS,NEWYORK],cardinality:3.0}",
+            "{type:distribution,columns:[MGR,COMM],cardinality:5.0}",
+            "{type:distribution,columns:[MGR,DEPTNO0],cardinality:9.0}",
+            "{type:distribution,columns:[MGR,DEPTNO],cardinality:9.0}",
+            "{type:distribution,columns:[MGR,DNAME],cardinality:9.0}",
+            "{type:distribution,columns:[MGR,LOC],cardinality:9.0}",
+            "{type:distribution,columns:[MGR,SAL],cardinality:12.0}",
+            "{type:distribution,columns:[MGR],values:[7566,7698,7782,7788,7839,7902],cardinality:7.0,nullCount:1}",
+            "{type:distribution,columns:[SAL,COMM],cardinality:5.0}",
+            "{type:distribution,columns:[SAL,DEPTNO0],cardinality:12.0}",
+            "{type:distribution,columns:[SAL,DEPTNO],cardinality:12.0}",
+            "{type:distribution,columns:[SAL,DNAME],cardinality:12.0}",
+            "{type:distribution,columns:[SAL,LOC],cardinality:12.0}",
+            "{type:distribution,columns:[SAL],values:[800.00,950.00,1100.00,1250.00,1300.00,1500.00,1600.00,2450.00,2850.00,2975.00,3000.00,5000.00],cardinality:12.0}",
+            "{type:distribution,columns:[],cardinality:1.0}",
+            "{type:fd,columns:[DEPTNO0],dependentColumn:DEPTNO}",
+            "{type:fd,columns:[DEPTNO0],dependentColumn:DNAME}",
+            "{type:fd,columns:[DEPTNO0],dependentColumn:LOC}",
+            "{type:fd,columns:[DEPTNO],dependentColumn:DEPTNO0}",
+            "{type:fd,columns:[DEPTNO],dependentColumn:DNAME}",
+            "{type:fd,columns:[DEPTNO],dependentColumn:LOC}",
+            "{type:fd,columns:[DNAME],dependentColumn:DEPTNO0}",
+            "{type:fd,columns:[DNAME],dependentColumn:DEPTNO}",
+            "{type:fd,columns:[DNAME],dependentColumn:LOC}",
+            "{type:fd,columns:[JOB],dependentColumn:COMM}",
+            "{type:fd,columns:[LOC],dependentColumn:DEPTNO0}",
+            "{type:fd,columns:[LOC],dependentColumn:DEPTNO}",
+            "{type:fd,columns:[LOC],dependentColumn:DNAME}",
+            "{type:fd,columns:[SAL],dependentColumn:DEPTNO0}",
+            "{type:fd,columns:[SAL],dependentColumn:DEPTNO}",
+            "{type:fd,columns:[SAL],dependentColumn:DNAME}",
+            "{type:fd,columns:[SAL],dependentColumn:JOB}",
+            "{type:fd,columns:[SAL],dependentColumn:LOC}",
+            "{type:fd,columns:[SAL],dependentColumn:MGR}",
+            "{type:rowCount,rowCount:14}",
+            "{type:unique,columns:[EMPNO]}",
+            "{type:unique,columns:[ENAME]}",
+            "{type:unique,columns:[HIREDATE,DEPTNO0]}",
+            "{type:unique,columns:[HIREDATE,DEPTNO]}",
+            "{type:unique,columns:[HIREDATE,DNAME]}",
+            "{type:unique,columns:[HIREDATE,LOC]}",
+            "{type:unique,columns:[HIREDATE,SAL]}",
+            "{type:unique,columns:[JOB,HIREDATE]}");
   }
 
   /** As {@link #testProfileScott()}, but prints only the most surprising
@@ -400,27 +393,15 @@ public class ProfilerTest {
 
   private static Fluid sql(String sql) {
     return new Fluid(CalciteAssert.Config.SCOTT, sql, Fluid.SIMPLE_FACTORY,
-        Predicates.<Profiler.Statistic>alwaysTrue(), null, -1,
-        Fluid.DEFAULT_COLUMNS);
+        s -> true, null, -1, Fluid.DEFAULT_COLUMNS);
   }
 
   /** Fluid interface for writing profiler test cases. */
   private static class Fluid {
-    static final Supplier<Profiler> SIMPLE_FACTORY =
-        new Supplier<Profiler>() {
-          public Profiler get() {
-            return new SimpleProfiler();
-          }
-        };
+    static final Supplier<Profiler> SIMPLE_FACTORY = SimpleProfiler::new;
 
     static final Supplier<Profiler> BETTER_FACTORY =
-        new Supplier<Profiler>() {
-          public Profiler get() {
-            final Predicate<Pair<ProfilerImpl.Space, Profiler.Column>>
-                predicate = Predicates.alwaysTrue();
-            return new ProfilerImpl(600, 200, predicate);
-          }
-        };
+        () -> new ProfilerImpl(600, 200, p -> true);
 
     static final Ordering<Profiler.Statistic> ORDERING =
         new Ordering<Profiler.Statistic>() {
@@ -443,18 +424,10 @@ public class ProfilerTest {
         };
 
     static final Predicate<Profiler.Statistic> STATISTIC_PREDICATE =
-        new PredicateImpl<Profiler.Statistic>() {
-          public boolean test(Profiler.Statistic statistic) {
-            // Include distributions of zero columns (the grand total)
-            // and singleton columns, plus "surprising" distributions
-            // (with significantly higher NDVs than predicted from their
-            // constituent columns).
-            return statistic instanceof Profiler.Distribution
-                && (((Profiler.Distribution) statistic).columns.size() < 2
-                || ((Profiler.Distribution) statistic).surprise() > 0.4D)
-                && ((Profiler.Distribution) statistic).minimal;
-          }
-        };
+        statistic -> statistic instanceof Profiler.Distribution
+            && (((Profiler.Distribution) statistic).columns.size() < 2
+            || ((Profiler.Distribution) statistic).surprise() > 0.4D)
+            && ((Profiler.Distribution) statistic).minimal;
 
     static final List<String> DEFAULT_COLUMNS =
         ImmutableList.of("type", "distribution", "columns", "cardinality",
@@ -465,34 +438,20 @@ public class ProfilerTest {
             .add("expectedCardinality", "surprise")
             .build();
 
-    private static final Supplier<Profiler> PROFILER_FACTORY =
-        new Supplier<Profiler>() {
-          public Profiler get() {
-            return new ProfilerImpl(7500, 100,
-                new PredicateImpl<Pair<ProfilerImpl.Space, Profiler.Column>>() {
-                  public boolean test(
-                      Pair<ProfilerImpl.Space, Profiler.Column> p) {
-                    final Profiler.Distribution distribution =
-                        p.left.distribution();
-                    if (distribution == null) {
-                      // We don't have a distribution yet, because this space
-                      // has not yet been evaluated. Let's do it anyway.
-                      return true;
-                    }
-                    return distribution.surprise() >= 0.3D;
-                  }
-                });
+    private static final Supplier<Profiler> PROFILER_FACTORY = () ->
+        new ProfilerImpl(7500, 100, p -> {
+          final Profiler.Distribution distribution =
+              p.left.distribution();
+          if (distribution == null) {
+            // We don't have a distribution yet, because this space
+            // has not yet been evaluated. Let's do it anyway.
+            return true;
           }
-        };
+          return distribution.surprise() >= 0.3D;
+        });
 
     private static final Supplier<Profiler> INCURIOUS_PROFILER_FACTORY =
-        new Supplier<Profiler>() {
-          public Profiler get() {
-            final Predicate<Pair<ProfilerImpl.Space, Profiler.Column>> p =
-                Predicates.alwaysFalse();
-            return new ProfilerImpl(10, 200, p);
-          }
-        };
+        () -> new ProfilerImpl(10, 200, p -> false);
 
     private final String sql;
     private final List<String> columns;
@@ -506,10 +465,10 @@ public class ProfilerTest {
         Predicate<Profiler.Statistic> predicate,
         Comparator<Profiler.Statistic> comparator, int limit,
         List<String> columns) {
-      this.sql = Preconditions.checkNotNull(sql);
-      this.factory = Preconditions.checkNotNull(factory);
+      this.sql = Objects.requireNonNull(sql);
+      this.factory = Objects.requireNonNull(factory);
       this.columns = ImmutableList.copyOf(columns);
-      this.predicate = Preconditions.checkNotNull(predicate);
+      this.predicate = Objects.requireNonNull(predicate);
       this.comparator = comparator; // null means sort on JSON representation
       this.limit = limit;
       this.config = config;
@@ -552,80 +511,58 @@ public class ProfilerTest {
     public Fluid check(final Matcher<Iterable<String>> matcher)
         throws Exception {
       CalciteAssert.that(config)
-          .doWithConnection(new Function<CalciteConnection, Void>() {
-            public Void apply(CalciteConnection c) {
-              try (PreparedStatement s = c.prepareStatement(sql)) {
-                final ResultSetMetaData m = s.getMetaData();
-                final List<Profiler.Column> columns = new ArrayList<>();
-                final int columnCount = m.getColumnCount();
-                for (int i = 0; i < columnCount; i++) {
-                  columns.add(new Profiler.Column(i, m.getColumnLabel(i + 1)));
-                }
-
-                // Create an initial group for each table in the query.
-                // Columns in the same table will tend to have the same
-                // cardinality as the table, and as the table's primary key.
-                final Multimap<String, Integer> groups = HashMultimap.create();
-                for (int i = 0; i < m.getColumnCount(); i++) {
-                  groups.put(m.getTableName(i + 1), i);
-                }
-                final SortedSet<ImmutableBitSet> initialGroups =
-                    new TreeSet<>();
-                for (Collection<Integer> integers : groups.asMap().values()) {
-                  initialGroups.add(ImmutableBitSet.of(integers));
-                }
-                final Profiler p = factory.get();
-                final Enumerable<List<Comparable>> rows = getRows(s);
-                final Profiler.Profile profile =
-                    p.profile(rows, columns, initialGroups);
-                final List<Profiler.Statistic> statistics =
-                    ImmutableList.copyOf(
-                        Iterables.filter(profile.statistics(), predicate));
-
-                // If no comparator specified, use the function that converts to
-                // JSON strings
-                final Function<Profiler.Statistic, String> toJson =
-                    toJsonFunction();
-                Ordering<Profiler.Statistic> comp = comparator != null
-                    ? Ordering.from(comparator)
-                    : Ordering.natural().onResultOf(toJson);
-                ImmutableList<Profiler.Statistic> statistics2 =
-                    comp.immutableSortedCopy(statistics);
-                if (limit >= 0 && limit < statistics2.size()) {
-                  statistics2 = statistics2.subList(0, limit);
-                }
-
-                final List<String> strings =
-                    Lists.transform(statistics2, toJson);
-                assertThat(strings, matcher);
-              } catch (SQLException e) {
-                throw new RuntimeException(e);
+          .doWithConnection(c -> {
+            try (PreparedStatement s = c.prepareStatement(sql)) {
+              final ResultSetMetaData m = s.getMetaData();
+              final List<Profiler.Column> columns = new ArrayList<>();
+              final int columnCount = m.getColumnCount();
+              for (int i = 0; i < columnCount; i++) {
+                columns.add(new Profiler.Column(i, m.getColumnLabel(i + 1)));
+              }
+
+              // Create an initial group for each table in the query.
+              // Columns in the same table will tend to have the same
+              // cardinality as the table, and as the table's primary key.
+              final Multimap<String, Integer> groups = HashMultimap.create();
+              for (int i = 0; i < m.getColumnCount(); i++) {
+                groups.put(m.getTableName(i + 1), i);
+              }
+              final SortedSet<ImmutableBitSet> initialGroups =
+                  new TreeSet<>();
+              for (Collection<Integer> integers : groups.asMap().values()) {
+                initialGroups.add(ImmutableBitSet.of(integers));
               }
-              return null;
+              final Profiler p = factory.get();
+              final Enumerable<List<Comparable>> rows = getRows(s);
+              final Profiler.Profile profile =
+                  p.profile(rows, columns, initialGroups);
+              final List<Profiler.Statistic> statistics =
+                  profile.statistics().stream().filter(predicate)
+                      .collect(Util.toImmutableList());
+
+              // If no comparator specified, use the function that converts to
+              // JSON strings
+              final StatisticToJson toJson = new StatisticToJson();
+              Ordering<Profiler.Statistic> comp = comparator != null
+                  ? Ordering.from(comparator)
+                  : Ordering.natural().onResultOf(toJson::apply);
+              ImmutableList<Profiler.Statistic> statistics2 =
+                  comp.immutableSortedCopy(statistics);
+              if (limit >= 0 && limit < statistics2.size()) {
+                statistics2 = statistics2.subList(0, limit);
+              }
+
+              final List<String> strings =
+                  statistics2.stream().map(toJson::apply)
+                      .collect(Collectors.toList());
+              assertThat(strings, matcher);
+            } catch (SQLException e) {
+              throw new RuntimeException(e);
             }
           });
       return this;
     }
 
-    /** Returns a function that converts a statistic to a JSON string. */
-    Function<Profiler.Statistic, String> toJsonFunction() {
-      return new Function<Profiler.Statistic, String>() {
-        final JsonBuilder jb = new JsonBuilder();
-
-        public String apply(Profiler.Statistic statistic) {
-          Object map = statistic.toMap(jb);
-          if (map instanceof Map) {
-            @SuppressWarnings("unchecked")
-            final Map<String, Object> map1 = (Map) map;
-            map1.keySet().retainAll(Fluid.this.columns);
-          }
-          final String json = jb.toJsonString(map);
-          return json.replaceAll("\n", "").replaceAll(" ", "")
-              .replaceAll("\"", "");
-        }
-      };
-    }
-
     private Enumerable<List<Comparable>> getRows(final PreparedStatement s) {
       return new AbstractEnumerable<List<Comparable>>() {
         public Enumerator<List<Comparable>> enumerator() {
@@ -676,6 +613,23 @@ public class ProfilerTest {
         }
       };
     }
+
+    /** Returns a function that converts a statistic to a JSON string. */
+    private class StatisticToJson {
+      final JsonBuilder jb = new JsonBuilder();
+
+      public String apply(Profiler.Statistic statistic) {
+        Object map = statistic.toMap(jb);
+        if (map instanceof Map) {
+          @SuppressWarnings("unchecked")
+          final Map<String, Object> map1 = (Map) map;
+          map1.keySet().retainAll(Fluid.this.columns);
+        }
+        final String json = jb.toJsonString(map);
+        return json.replaceAll("\n", "").replaceAll(" ", "")
+            .replaceAll("\"", "");
+      }
+    }
   }
 }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/rel/RelCollationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/rel/RelCollationTest.java b/core/src/test/java/org/apache/calcite/rel/RelCollationTest.java
index 84c816b..552c183 100644
--- a/core/src/test/java/org/apache/calcite/rel/RelCollationTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/RelCollationTest.java
@@ -16,10 +16,9 @@
  */
 package org.apache.calcite.rel;
 
-import com.google.common.collect.Lists;
-
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -49,7 +48,7 @@ public class RelCollationTest {
         is(false));
     assertThat(RelCollations.contains(collation21, Arrays.asList(2, 1, 3)),
         is(false));
-    assertThat(RelCollations.contains(collation21, Arrays.<Integer>asList()),
+    assertThat(RelCollations.contains(collation21, Arrays.asList()),
         is(true));
 
     // if there are duplicates in keys, later occurrences are ignored
@@ -73,7 +72,7 @@ public class RelCollationTest {
         is(false));
     assertThat(RelCollations.contains(collation1, Arrays.asList(1, 2, 1)),
         is(false));
-    assertThat(RelCollations.contains(collation1, Arrays.<Integer>asList()),
+    assertThat(RelCollations.contains(collation1, Arrays.asList()),
         is(true));
   }
 
@@ -90,7 +89,7 @@ public class RelCollationTest {
   }
 
   private static RelCollation collation(int... ordinals) {
-    final List<RelFieldCollation> list = Lists.newArrayList();
+    final List<RelFieldCollation> list = new ArrayList<>();
     for (int ordinal : ordinals) {
       list.add(new RelFieldCollation(ordinal));
     }

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index 6673fac..53ba8a9 100644
--- a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -17,8 +17,6 @@
 package org.apache.calcite.rel.rel2sql;
 
 import org.apache.calcite.config.NullCollation;
-import org.apache.calcite.plan.RelOptLattice;
-import org.apache.calcite.plan.RelOptMaterialization;
 import org.apache.calcite.plan.RelOptPlanner;
 import org.apache.calcite.plan.RelTraitDef;
 import org.apache.calcite.plan.hep.HepPlanner;
@@ -46,14 +44,12 @@ import org.apache.calcite.tools.Programs;
 import org.apache.calcite.tools.RuleSet;
 import org.apache.calcite.tools.RuleSets;
 
-import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 
 import org.junit.Test;
 
 import java.util.List;
-
-import junit.framework.AssertionFailedError;
+import java.util.function.Function;
 
 import static org.apache.calcite.test.Matchers.isLinux;
 
@@ -81,7 +77,7 @@ public class RelToSqlConverterTest {
   private Sql sql(String sql) {
     return new Sql(CalciteAssert.SchemaSpec.JDBC_FOODMART, sql,
         CalciteSqlDialect.DEFAULT, DEFAULT_REL_CONFIG,
-        ImmutableList.<Function<RelNode, RelNode>>of());
+        ImmutableList.of());
   }
 
   private static Planner getPlanner(List<RelTraitDef> traitDefs,
@@ -2578,13 +2574,10 @@ public class RelToSqlConverterTest {
 
     Sql optimize(final RuleSet ruleSet, final RelOptPlanner relOptPlanner) {
       return new Sql(schemaSpec, sql, dialect, config,
-          FlatLists.append(transforms, new Function<RelNode, RelNode>() {
-            public RelNode apply(RelNode r) {
-              Program program = Programs.of(ruleSet);
-              return program.run(relOptPlanner, r, r.getTraitSet(),
-                  ImmutableList.<RelOptMaterialization>of(),
-                  ImmutableList.<RelOptLattice>of());
-            }
+          FlatLists.append(transforms, r -> {
+            Program program = Programs.of(ruleSet);
+            return program.run(relOptPlanner, r, r.getTraitSet(),
+                ImmutableList.of(), ImmutableList.of());
           }));
     }
 
@@ -2596,7 +2589,7 @@ public class RelToSqlConverterTest {
     Sql throws_(String errorMessage) {
       try {
         final String s = exec();
-        throw new AssertionFailedError("Expected exception with message `"
+        throw new AssertionError("Expected exception with message `"
             + errorMessage + "` but nothing was thrown; got " + s);
       } catch (Exception e) {
         assertThat(e.getMessage(), is(errorMessage));

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/rel/rules/DateRangeRulesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/rel/rules/DateRangeRulesTest.java b/core/src/test/java/org/apache/calcite/rel/rules/DateRangeRulesTest.java
index 01fe9bc..88312fe 100644
--- a/core/src/test/java/org/apache/calcite/rel/rules/DateRangeRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rules/DateRangeRulesTest.java
@@ -745,26 +745,26 @@ public class DateRangeRulesTest {
           ImmutableList.of(rexBuilder.makeFlag(TimeUnitRange.DAY), d));
 
       floorYear = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.FLOOR,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.YEAR)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.YEAR)));
       floorMonth = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.FLOOR,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.MONTH)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.MONTH)));
       floorDay = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.FLOOR,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.DAY)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.DAY)));
       floorHour = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.FLOOR,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.HOUR)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.HOUR)));
       floorMinute = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.FLOOR,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.MINUTE)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.MINUTE)));
 
       ceilYear = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.CEIL,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.YEAR)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.YEAR)));
       ceilMonth = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.CEIL,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.MONTH)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.MONTH)));
       ceilDay = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.CEIL,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.DAY)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.DAY)));
       ceilHour = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.CEIL,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.HOUR)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.HOUR)));
       ceilMinute = rexBuilder.makeCall(intRelDataType, SqlStdOperatorTable.CEIL,
-          ImmutableList.<RexNode>of(ts, rexBuilder.makeFlag(TimeUnitRange.MINUTE)));
+          ImmutableList.of(ts, rexBuilder.makeFlag(TimeUnitRange.MINUTE)));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java b/core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
index d421033..4e20d2c 100644
--- a/core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
+++ b/core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
@@ -40,7 +40,6 @@ import org.apache.calcite.util.DateString;
 import org.apache.calcite.util.NlsString;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 
 import org.junit.Assert;
@@ -50,6 +49,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Random;
+import java.util.function.Function;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -84,56 +84,51 @@ public class RexExecutorTest {
   /** Tests an executor that uses variables stored in a {@link DataContext}.
    * Can change the value of the variable and execute again. */
   @Test public void testVariableExecution() throws Exception {
-    check(
-        new Action() {
-          public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-            Object[] values = new Object[1];
-            final DataContext testContext = new TestDataContext(values);
-            final RelDataTypeFactory typeFactory = rexBuilder.getTypeFactory();
-            final RelDataType varchar =
-                typeFactory.createSqlType(SqlTypeName.VARCHAR);
-            final RelDataType integer =
-                typeFactory.createSqlType(SqlTypeName.INTEGER);
-            // Calcite is internally creating the input ref via a RexRangeRef
-            // which eventually leads to a RexInputRef. So we are good.
-            final RexInputRef input = rexBuilder.makeInputRef(varchar, 0);
-            final RexNode lengthArg = rexBuilder.makeLiteral(3, integer, true);
-            final RexNode substr =
-                rexBuilder.makeCall(SqlStdOperatorTable.SUBSTRING, input,
-                    lengthArg);
-            ImmutableList<RexNode> constExps = ImmutableList.of(substr);
+    check((rexBuilder, executor) -> {
+      Object[] values = new Object[1];
+      final DataContext testContext = new TestDataContext(values);
+      final RelDataTypeFactory typeFactory = rexBuilder.getTypeFactory();
+      final RelDataType varchar =
+          typeFactory.createSqlType(SqlTypeName.VARCHAR);
+      final RelDataType integer =
+          typeFactory.createSqlType(SqlTypeName.INTEGER);
+      // Calcite is internally creating the input ref via a RexRangeRef
+      // which eventually leads to a RexInputRef. So we are good.
+      final RexInputRef input = rexBuilder.makeInputRef(varchar, 0);
+      final RexNode lengthArg = rexBuilder.makeLiteral(3, integer, true);
+      final RexNode substr =
+          rexBuilder.makeCall(SqlStdOperatorTable.SUBSTRING, input,
+              lengthArg);
+      ImmutableList<RexNode> constExps = ImmutableList.of(substr);
 
-            final RelDataType rowType = typeFactory.builder()
-                .add("someStr", varchar)
-                .build();
+      final RelDataType rowType = typeFactory.builder()
+          .add("someStr", varchar)
+          .build();
 
-            final RexExecutable exec = executor.getExecutable(rexBuilder,
-                constExps, rowType);
-            exec.setDataContext(testContext);
-            values[0] = "Hello World";
-            Object[] result = exec.execute();
-            assertTrue(result[0] instanceof String);
-            assertThat((String) result[0], equalTo("llo World"));
-            values[0] = "Calcite";
-            result = exec.execute();
-            assertTrue(result[0] instanceof String);
-            assertThat((String) result[0], equalTo("lcite"));
-          }
-        });
+      final RexExecutable exec = executor.getExecutable(rexBuilder,
+          constExps, rowType);
+      exec.setDataContext(testContext);
+      values[0] = "Hello World";
+      Object[] result = exec.execute();
+      assertTrue(result[0] instanceof String);
+      assertThat((String) result[0], equalTo("llo World"));
+      values[0] = "Calcite";
+      result = exec.execute();
+      assertTrue(result[0] instanceof String);
+      assertThat((String) result[0], equalTo("lcite"));
+    });
   }
 
   @Test public void testConstant() throws Exception {
-    check(new Action() {
-      public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-        final List<RexNode> reducedValues = new ArrayList<>();
-        final RexLiteral ten = rexBuilder.makeExactLiteral(BigDecimal.TEN);
-        executor.reduce(rexBuilder, ImmutableList.<RexNode>of(ten),
-            reducedValues);
-        assertThat(reducedValues.size(), equalTo(1));
-        assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
-        assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
-            equalTo((Object) 10L));
-      }
+    check((rexBuilder, executor) -> {
+      final List<RexNode> reducedValues = new ArrayList<>();
+      final RexLiteral ten = rexBuilder.makeExactLiteral(BigDecimal.TEN);
+      executor.reduce(rexBuilder, ImmutableList.of(ten),
+          reducedValues);
+      assertThat(reducedValues.size(), equalTo(1));
+      assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
+      assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
+          equalTo((Object) 10L));
     });
   }
 
@@ -141,154 +136,127 @@ public class RexExecutorTest {
   @Test public void testConstant2() throws Exception {
     // Same as testConstant; 10 -> 10
     checkConstant(10L,
-        new Function<RexBuilder, RexNode>() {
-          public RexNode apply(RexBuilder rexBuilder) {
-            return rexBuilder.makeExactLiteral(BigDecimal.TEN);
-          }
-        });
+        rexBuilder -> rexBuilder.makeExactLiteral(BigDecimal.TEN));
     // 10 + 1 -> 11
     checkConstant(11L,
-        new Function<RexBuilder, RexNode>() {
-          public RexNode apply(RexBuilder rexBuilder) {
-            return rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
-                rexBuilder.makeExactLiteral(BigDecimal.TEN),
-                rexBuilder.makeExactLiteral(BigDecimal.ONE));
-          }
-        });
+        rexBuilder -> rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
+            rexBuilder.makeExactLiteral(BigDecimal.TEN),
+            rexBuilder.makeExactLiteral(BigDecimal.ONE)));
     // date 'today' <= date 'today' -> true
-    checkConstant(true,
-        new Function<RexBuilder, RexNode>() {
-          public RexNode apply(RexBuilder rexBuilder) {
-            final DateString d =
-                DateString.fromCalendarFields(Util.calendar());
-            return rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN_OR_EQUAL,
-                rexBuilder.makeDateLiteral(d),
-                rexBuilder.makeDateLiteral(d));
-          }
-        });
+    checkConstant(true, rexBuilder -> {
+      final DateString d =
+          DateString.fromCalendarFields(Util.calendar());
+      return rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN_OR_EQUAL,
+          rexBuilder.makeDateLiteral(d),
+          rexBuilder.makeDateLiteral(d));
+    });
     // date 'today' < date 'today' -> false
-    checkConstant(false,
-        new Function<RexBuilder, RexNode>() {
-          public RexNode apply(RexBuilder rexBuilder) {
-            final DateString d =
-                DateString.fromCalendarFields(Util.calendar());
-            return rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN,
-                rexBuilder.makeDateLiteral(d),
-                rexBuilder.makeDateLiteral(d));
-          }
-        });
+    checkConstant(false, rexBuilder -> {
+      final DateString d =
+          DateString.fromCalendarFields(Util.calendar());
+      return rexBuilder.makeCall(SqlStdOperatorTable.LESS_THAN,
+          rexBuilder.makeDateLiteral(d),
+          rexBuilder.makeDateLiteral(d));
+    });
   }
 
   private void checkConstant(final Object operand,
       final Function<RexBuilder, RexNode> function) throws Exception {
-    check(
-        new Action() {
-          public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-            final List<RexNode> reducedValues = new ArrayList<>();
-            final RexNode expression = function.apply(rexBuilder);
-            assert expression != null;
-            executor.reduce(rexBuilder, ImmutableList.of(expression),
-                reducedValues);
-            assertThat(reducedValues.size(), equalTo(1));
-            assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
-            assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
-                equalTo(operand));
-          }
-        });
+    check((rexBuilder, executor) -> {
+      final List<RexNode> reducedValues = new ArrayList<>();
+      final RexNode expression = function.apply(rexBuilder);
+      assert expression != null;
+      executor.reduce(rexBuilder, ImmutableList.of(expression),
+          reducedValues);
+      assertThat(reducedValues.size(), equalTo(1));
+      assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
+      assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
+          equalTo(operand));
+    });
   }
 
   @Test public void testSubstring() throws Exception {
-    check(new Action() {
-      public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-        final List<RexNode> reducedValues = new ArrayList<>();
-        final RexLiteral hello =
-            rexBuilder.makeCharLiteral(
-                new NlsString("Hello world!", null, null));
-        final RexNode plus =
-            rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
-                rexBuilder.makeExactLiteral(BigDecimal.ONE),
-                rexBuilder.makeExactLiteral(BigDecimal.ONE));
-        RexLiteral four = rexBuilder.makeExactLiteral(BigDecimal.valueOf(4));
-        final RexNode substring =
-            rexBuilder.makeCall(SqlStdOperatorTable.SUBSTRING,
-                hello, plus, four);
-        executor.reduce(rexBuilder, ImmutableList.of(substring, plus),
-            reducedValues);
-        assertThat(reducedValues.size(), equalTo(2));
-        assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
-        assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
-            equalTo((Object) "ello")); // substring('Hello world!, 2, 4)
-        assertThat(reducedValues.get(1), instanceOf(RexLiteral.class));
-        assertThat(((RexLiteral) reducedValues.get(1)).getValue2(),
-            equalTo((Object) 2L));
-      }
+    check((rexBuilder, executor) -> {
+      final List<RexNode> reducedValues = new ArrayList<>();
+      final RexLiteral hello =
+          rexBuilder.makeCharLiteral(
+              new NlsString("Hello world!", null, null));
+      final RexNode plus =
+          rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
+              rexBuilder.makeExactLiteral(BigDecimal.ONE),
+              rexBuilder.makeExactLiteral(BigDecimal.ONE));
+      RexLiteral four = rexBuilder.makeExactLiteral(BigDecimal.valueOf(4));
+      final RexNode substring =
+          rexBuilder.makeCall(SqlStdOperatorTable.SUBSTRING,
+              hello, plus, four);
+      executor.reduce(rexBuilder, ImmutableList.of(substring, plus),
+          reducedValues);
+      assertThat(reducedValues.size(), equalTo(2));
+      assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
+      assertThat(((RexLiteral) reducedValues.get(0)).getValue2(),
+          equalTo((Object) "ello")); // substring('Hello world!, 2, 4)
+      assertThat(reducedValues.get(1), instanceOf(RexLiteral.class));
+      assertThat(((RexLiteral) reducedValues.get(1)).getValue2(),
+          equalTo((Object) 2L));
     });
   }
 
   @Test public void testBinarySubstring() throws Exception {
-    check(new Action() {
-      public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-        final List<RexNode> reducedValues = new ArrayList<>();
-        // hello world! -> 48656c6c6f20776f726c6421
-        final RexLiteral binaryHello =
-            rexBuilder.makeBinaryLiteral(
-                new ByteString("Hello world!".getBytes(UTF_8)));
-        final RexNode plus =
-            rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
-                rexBuilder.makeExactLiteral(BigDecimal.ONE),
-                rexBuilder.makeExactLiteral(BigDecimal.ONE));
-        RexLiteral four = rexBuilder.makeExactLiteral(BigDecimal.valueOf(4));
-        final RexNode substring =
-            rexBuilder.makeCall(SqlStdOperatorTable.SUBSTRING,
-                binaryHello, plus, four);
-        executor.reduce(rexBuilder, ImmutableList.of(substring, plus),
-            reducedValues);
-        assertThat(reducedValues.size(), equalTo(2));
-        assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
-        assertThat(((RexLiteral) reducedValues.get(0)).getValue2().toString(),
-            equalTo((Object) "656c6c6f")); // substring('Hello world!, 2, 4)
-        assertThat(reducedValues.get(1), instanceOf(RexLiteral.class));
-        assertThat(((RexLiteral) reducedValues.get(1)).getValue2(),
-            equalTo((Object) 2L));
-      }
+    check((rexBuilder, executor) -> {
+      final List<RexNode> reducedValues = new ArrayList<>();
+      // hello world! -> 48656c6c6f20776f726c6421
+      final RexLiteral binaryHello =
+          rexBuilder.makeBinaryLiteral(
+              new ByteString("Hello world!".getBytes(UTF_8)));
+      final RexNode plus =
+          rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
+              rexBuilder.makeExactLiteral(BigDecimal.ONE),
+              rexBuilder.makeExactLiteral(BigDecimal.ONE));
+      RexLiteral four = rexBuilder.makeExactLiteral(BigDecimal.valueOf(4));
+      final RexNode substring =
+          rexBuilder.makeCall(SqlStdOperatorTable.SUBSTRING,
+              binaryHello, plus, four);
+      executor.reduce(rexBuilder, ImmutableList.of(substring, plus),
+          reducedValues);
+      assertThat(reducedValues.size(), equalTo(2));
+      assertThat(reducedValues.get(0), instanceOf(RexLiteral.class));
+      assertThat(((RexLiteral) reducedValues.get(0)).getValue2().toString(),
+          equalTo((Object) "656c6c6f")); // substring('Hello world!, 2, 4)
+      assertThat(reducedValues.get(1), instanceOf(RexLiteral.class));
+      assertThat(((RexLiteral) reducedValues.get(1)).getValue2(),
+          equalTo((Object) 2L));
     });
   }
 
   @Test public void testDeterministic1() throws Exception {
-    check(new Action() {
-      public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-        final RexNode plus =
-            rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
-                rexBuilder.makeExactLiteral(BigDecimal.ONE),
-                rexBuilder.makeExactLiteral(BigDecimal.ONE));
-        assertThat(RexUtil.isDeterministic(plus), equalTo(true));
-      }
+    check((rexBuilder, executor) -> {
+      final RexNode plus =
+          rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
+              rexBuilder.makeExactLiteral(BigDecimal.ONE),
+              rexBuilder.makeExactLiteral(BigDecimal.ONE));
+      assertThat(RexUtil.isDeterministic(plus), equalTo(true));
     });
   }
 
   @Test public void testDeterministic2() throws Exception {
-    check(new Action() {
-      public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-        final RexNode plus =
-            rexBuilder.makeCall(PLUS_RANDOM,
-                rexBuilder.makeExactLiteral(BigDecimal.ONE),
-                rexBuilder.makeExactLiteral(BigDecimal.ONE));
-        assertThat(RexUtil.isDeterministic(plus), equalTo(false));
-      }
+    check((rexBuilder, executor) -> {
+      final RexNode plus =
+          rexBuilder.makeCall(PLUS_RANDOM,
+              rexBuilder.makeExactLiteral(BigDecimal.ONE),
+              rexBuilder.makeExactLiteral(BigDecimal.ONE));
+      assertThat(RexUtil.isDeterministic(plus), equalTo(false));
     });
   }
 
   @Test public void testDeterministic3() throws Exception {
-    check(new Action() {
-      public void check(RexBuilder rexBuilder, RexExecutorImpl executor) {
-        final RexNode plus =
-            rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
-                rexBuilder.makeCall(PLUS_RANDOM,
-                    rexBuilder.makeExactLiteral(BigDecimal.ONE),
-                    rexBuilder.makeExactLiteral(BigDecimal.ONE)),
-                rexBuilder.makeExactLiteral(BigDecimal.ONE));
-        assertThat(RexUtil.isDeterministic(plus), equalTo(false));
-      }
+    check((rexBuilder, executor) -> {
+      final RexNode plus =
+          rexBuilder.makeCall(SqlStdOperatorTable.PLUS,
+              rexBuilder.makeCall(PLUS_RANDOM,
+                  rexBuilder.makeExactLiteral(BigDecimal.ONE),
+                  rexBuilder.makeExactLiteral(BigDecimal.ONE)),
+              rexBuilder.makeExactLiteral(BigDecimal.ONE));
+      assertThat(RexUtil.isDeterministic(plus), equalTo(false));
     });
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/runtime/BinarySearchTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/runtime/BinarySearchTest.java b/core/src/test/java/org/apache/calcite/runtime/BinarySearchTest.java
index 345a324..15b34a9 100644
--- a/core/src/test/java/org/apache/calcite/runtime/BinarySearchTest.java
+++ b/core/src/test/java/org/apache/calcite/runtime/BinarySearchTest.java
@@ -30,10 +30,10 @@ public class BinarySearchTest {
   private void search(int key, int lower, int upper, Integer... array) {
     Assert.assertEquals(
         "lower bound of " + key + " in " + Arrays.toString(array), lower,
-        BinarySearch.lowerBound(array, key, Ordering.<Integer>natural()));
+        BinarySearch.lowerBound(array, key, Ordering.natural()));
     Assert.assertEquals(
         "upper bound of " + key + " in " + Arrays.toString(array), upper,
-        BinarySearch.upperBound(array, key, Ordering.<Integer>natural()));
+        BinarySearch.upperBound(array, key, Ordering.natural()));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/runtime/EnumerablesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/runtime/EnumerablesTest.java b/core/src/test/java/org/apache/calcite/runtime/EnumerablesTest.java
index 5e76578..aab9520 100644
--- a/core/src/test/java/org/apache/calcite/runtime/EnumerablesTest.java
+++ b/core/src/test/java/org/apache/calcite/runtime/EnumerablesTest.java
@@ -19,7 +19,6 @@ package org.apache.calcite.runtime;
 import org.apache.calcite.linq4j.Enumerable;
 import org.apache.calcite.linq4j.EnumerableDefaults;
 import org.apache.calcite.linq4j.Linq4j;
-import org.apache.calcite.linq4j.function.Function1;
 import org.apache.calcite.linq4j.function.Function2;
 import org.apache.calcite.linq4j.function.Functions;
 import org.apache.calcite.linq4j.function.Predicate2;
@@ -28,9 +27,12 @@ import com.google.common.collect.Lists;
 
 import org.junit.Test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
+import static com.google.common.collect.Lists.newArrayList;
+
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.junit.Assert.assertThat;
 
@@ -51,37 +53,19 @@ public class EnumerablesTest {
           new Dept(15, "Marketing")));
 
   private static final Function2<Emp, Dept, String> EMP_DEPT_TO_STRING =
-      new Function2<Emp, Dept, String>() {
-        public String apply(Emp v0, Dept v1) {
-          return "{" + (v0 == null ? null : v0.name)
-              + ", " + (v0 == null ? null : v0.deptno)
-              + ", " + (v1 == null ? null : v1.deptno)
-              + ", " + (v1 == null ? null : v1.name)
-              + "}";
-        }
-      };
+      (v0, v1) -> "{" + (v0 == null ? null : v0.name)
+          + ", " + (v0 == null ? null : v0.deptno)
+          + ", " + (v1 == null ? null : v1.deptno)
+          + ", " + (v1 == null ? null : v1.name)
+          + "}";
 
   private static final Predicate2<Emp, Dept> EQUAL_DEPTNO =
-      new Predicate2<Emp, Dept>() {
-        public boolean apply(Emp v0, Dept v1) {
-          return v0.deptno == v1.deptno;
-        }
-      };
+      (e, d) -> e.deptno == d.deptno;
 
   @Test public void testSemiJoin() {
     assertThat(
-        EnumerableDefaults.semiJoin(EMPS, DEPTS,
-            new Function1<Emp, Integer>() {
-              public Integer apply(Emp a0) {
-                return a0.deptno;
-              }
-            },
-            new Function1<Dept, Integer>() {
-              public Integer apply(Dept a0) {
-                return a0.deptno;
-              }
-            },
-            Functions.<Integer>identityComparer()).toList().toString(),
+        EnumerableDefaults.semiJoin(EMPS, DEPTS, e -> e.deptno, d -> d.deptno,
+            Functions.identityComparer()).toList().toString(),
         equalTo("[Emp(20, Theodore), Emp(20, Sebastian)]"));
   }
 
@@ -101,21 +85,9 @@ public class EnumerablesTest {
                     new Dept(20, "Sales"),
                     new Dept(30, "Research"),
                     new Dept(30, "Development"))),
-            new Function1<Emp, Integer>() {
-              public Integer apply(Emp a0) {
-                return a0.deptno;
-              }
-            },
-            new Function1<Dept, Integer>() {
-              public Integer apply(Dept a0) {
-                return a0.deptno;
-              }
-            },
-            new Function2<Emp, Dept, String>() {
-              public String apply(Emp v0, Dept v1) {
-                return v0 + ", " + v1;
-              }
-            }, false, false).toList().toString(),
+            e -> e.deptno,
+            d -> d.deptno,
+            (v0, v1) -> v0 + ", " + v1, false, false).toList().toString(),
         equalTo("[Emp(20, Theodore), Dept(20, Sales),"
             + " Emp(20, Sebastian), Dept(20, Sales),"
             + " Emp(30, Joe), Dept(30, Research),"
@@ -155,18 +127,18 @@ public class EnumerablesTest {
         equalTo("[]"));
     // Left empty
     assertThat(
-        intersect(Lists.<Integer>newArrayList(),
-            Lists.newArrayList(1, 3, 4, 6)).toList().toString(),
+        intersect(new ArrayList<>(),
+            newArrayList(1, 3, 4, 6)).toList().toString(),
         equalTo("[]"));
     // Right empty
     assertThat(
-        intersect(Lists.newArrayList(3, 7),
-            Lists.<Integer>newArrayList()).toList().toString(),
+        intersect(newArrayList(3, 7),
+            new ArrayList<>()).toList().toString(),
         equalTo("[]"));
     // Both empty
     assertThat(
-        intersect(Lists.<Integer>newArrayList(),
-            Lists.<Integer>newArrayList()).toList().toString(),
+        intersect(new ArrayList<Integer>(),
+            new ArrayList<>()).toList().toString(),
         equalTo("[]"));
   }
 
@@ -175,13 +147,8 @@ public class EnumerablesTest {
     return EnumerableDefaults.mergeJoin(
         Linq4j.asEnumerable(list0),
         Linq4j.asEnumerable(list1),
-        Functions.<T>identitySelector(),
-        Functions.<T>identitySelector(),
-        new Function2<T, T, T>() {
-          public T apply(T v0, T v1) {
-            return v0;
-          }
-        }, false, false);
+        Functions.identitySelector(),
+        Functions.identitySelector(), (v0, v1) -> v0, false, false);
   }
 
   @Test public void testThetaJoin() {
@@ -220,7 +187,7 @@ public class EnumerablesTest {
     assertThat(
         EnumerableDefaults.thetaJoin(EMPS.take(0), DEPTS, EQUAL_DEPTNO,
             EMP_DEPT_TO_STRING, true, true)
-            .orderBy(Functions.<String>identitySelector()).toList().toString(),
+            .orderBy(Functions.identitySelector()).toList().toString(),
         equalTo("[{null, null, 15, Marketing}, {null, null, 20, Sales}]"));
   }
 

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
index c3c1920..822c136 100644
--- a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
@@ -550,11 +550,7 @@ public class SqlParserTest {
   private static final String ANY = "(?s).*";
 
   private static final ThreadLocal<boolean[]> LINUXIFY =
-      new ThreadLocal<boolean[]>() {
-        @Override protected boolean[] initialValue() {
-          return new boolean[] {true};
-        }
-      };
+      ThreadLocal.withInitial(() -> new boolean[] {true});
 
   Quoting quoting = Quoting.DOUBLE_QUOTE;
   Casing unquotedCasing = Casing.TO_UPPER;

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java b/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
index ffdf886..e2667d5 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
@@ -73,30 +73,7 @@ public class DefaultSqlTestFactory implements SqlTestFactory {
    * Caching improves SqlValidatorTest from 23s to 8s,
    * and CalciteSqlOperatorTest from 65s to 43s. */
   private final LoadingCache<SqlTestFactory, Xyz> cache =
-      CacheBuilder.newBuilder()
-          .build(
-              new CacheLoader<SqlTestFactory, Xyz>() {
-                public Xyz load(@Nonnull SqlTestFactory factory)
-                    throws Exception {
-                  final SqlOperatorTable operatorTable =
-                      factory.createOperatorTable(factory);
-                  RelDataTypeSystem typeSystem = RelDataTypeSystem.DEFAULT;
-                  final SqlConformance conformance =
-                      (SqlConformance) factory.get("conformance");
-                  if (conformance.shouldConvertRaggedUnionTypesToVarying()) {
-                    typeSystem = new DelegatingTypeSystem(typeSystem) {
-                      public boolean shouldConvertRaggedUnionTypesToVarying() {
-                        return true;
-                      }
-                    };
-                  }
-                  final JavaTypeFactory typeFactory =
-                      new JavaTypeFactoryImpl(typeSystem);
-                  final MockCatalogReader catalogReader =
-                      factory.createCatalogReader(factory, typeFactory);
-                  return new Xyz(operatorTable, typeFactory, catalogReader);
-                }
-              });
+      CacheBuilder.newBuilder().build(CacheLoader.from(Xyz::from));
 
   public static final DefaultSqlTestFactory INSTANCE =
       new DefaultSqlTestFactory();
@@ -157,16 +134,24 @@ public class DefaultSqlTestFactory implements SqlTestFactory {
       this.catalogReader = catalogReader;
     }
 
-    public SqlOperatorTable getOperatorTable() {
-      return operatorTable;
-    }
-
-    public JavaTypeFactory getTypeFactory() {
-      return typeFactory;
-    }
-
-    public MockCatalogReader getCatalogReader() {
-      return catalogReader;
+    static Xyz from(@Nonnull SqlTestFactory factory) {
+      final SqlOperatorTable operatorTable =
+          factory.createOperatorTable(factory);
+      RelDataTypeSystem typeSystem = RelDataTypeSystem.DEFAULT;
+      final SqlConformance conformance =
+          (SqlConformance) factory.get("conformance");
+      if (conformance.shouldConvertRaggedUnionTypesToVarying()) {
+        typeSystem = new DelegatingTypeSystem(typeSystem) {
+          public boolean shouldConvertRaggedUnionTypesToVarying() {
+            return true;
+          }
+        };
+      }
+      final JavaTypeFactory typeFactory =
+          new JavaTypeFactoryImpl(typeSystem);
+      final MockCatalogReader catalogReader =
+          factory.createCatalogReader(factory, typeFactory);
+      return new Xyz(operatorTable, typeFactory, catalogReader);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
index afb60c1..e8b163a 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
@@ -57,9 +57,7 @@ import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.TimestampString;
 import org.apache.calcite.util.Util;
 
-import com.google.common.base.Function;
 import com.google.common.base.Throwables;
-import com.google.common.collect.Lists;
 
 import org.junit.Before;
 import org.junit.Ignore;
@@ -79,6 +77,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.TimeZone;
+import java.util.function.Consumer;
 import java.util.regex.Pattern;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -5083,9 +5082,7 @@ public abstract class SqlOperatorBaseTest {
     final Hook.Closeable closeable;
     if (CalciteAssert.ENABLE_SLOW) {
       calendar = getCalendarNotTooNear(Calendar.HOUR_OF_DAY);
-      closeable = new Hook.Closeable() {
-        public void close() {}
-      };
+      closeable = () -> { };
     } else {
       calendar = Util.calendar();
       calendar.set(Calendar.YEAR, 2014);
@@ -5097,12 +5094,7 @@ public abstract class SqlOperatorBaseTest {
       calendar.set(Calendar.MILLISECOND, 15);
       final long timeInMillis = calendar.getTimeInMillis();
       closeable = Hook.CURRENT_TIME.addThread(
-          new Function<Holder<Long>, Void>() {
-            public Void apply(Holder<Long> o) {
-              o.set(timeInMillis);
-              return null;
-            }
-          });
+          (Consumer<Holder<Long>>) o -> o.set(timeInMillis));
     }
 
     SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:", Locale.ROOT);
@@ -5530,7 +5522,8 @@ public abstract class SqlOperatorBaseTest {
         "Invalid number of arguments to function 'COLLECT'. Was expecting 1 arguments",
         false);
     final String[] values = {"0", "CAST(null AS INTEGER)", "2", "2"};
-    tester.checkAgg("collect(x)", values, Arrays.asList("[0, 2, 2]"), (double) 0);
+    tester.checkAgg("collect(x)", values,
+        Collections.singletonList("[0, 2, 2]"), (double) 0);
     Object result1 = -3;
     if (!enable) {
       return;
@@ -7470,7 +7463,7 @@ public abstract class SqlOperatorBaseTest {
                 query = SqlTesterImpl.buildQuery(s);
               }
               tester.check(query, SqlTests.ANY_TYPE_CHECKER,
-                  SqlTests.ANY_PARAMETER_CHECKER, SqlTests.ANY_RESULT_CHECKER);
+                  SqlTests.ANY_PARAMETER_CHECKER, result -> { });
             }
           } catch (Error e) {
             System.out.println(s + ": " + e.getMessage());
@@ -7674,8 +7667,8 @@ public abstract class SqlOperatorBaseTest {
   /** Builds lists of types and sample values. */
   static class Builder {
     final RelDataTypeFactory typeFactory;
-    final List<RelDataType> types = Lists.newArrayList();
-    final List<ValueType> values = Lists.newArrayList();
+    final List<RelDataType> types = new ArrayList<>();
+    final List<ValueType> values = new ArrayList<>();
 
     Builder(RelDataTypeFactory typeFactory) {
       this.typeFactory = typeFactory;

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java b/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
index c4eba51..d215b45 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlTesterImpl.java
@@ -56,8 +56,6 @@ import com.google.common.collect.ImmutableList;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -598,21 +596,15 @@ public class SqlTesterImpl implements SqlTester, AutoCloseable {
           }
         });
     final List<SqlNode> nodes = new ArrayList<>(literalSet);
-    Collections.sort(
-        nodes,
-        new Comparator<SqlNode>() {
-          public int compare(SqlNode o1, SqlNode o2) {
-            final SqlParserPos pos0 = o1.getParserPosition();
-            final SqlParserPos pos1 = o2.getParserPosition();
-            int c = -Utilities.compare(
-                pos0.getLineNum(), pos1.getLineNum());
-            if (c != 0) {
-              return c;
-            }
-            return -Utilities.compare(
-                pos0.getColumnNum(), pos1.getColumnNum());
-          }
-        });
+    nodes.sort((o1, o2) -> {
+      final SqlParserPos pos0 = o1.getParserPosition();
+      final SqlParserPos pos1 = o2.getParserPosition();
+      int c = -Utilities.compare(pos0.getLineNum(), pos1.getLineNum());
+      if (c != 0) {
+        return c;
+      }
+      return -Utilities.compare(pos0.getColumnNum(), pos1.getColumnNum());
+    });
     String sql2 = sql;
     final List<Pair<String, String>> values = new ArrayList<>();
     int p = 0;
@@ -655,30 +647,26 @@ public class SqlTesterImpl implements SqlTester, AutoCloseable {
     // Why an explicit iterable rather than a list? If there is
     // a syntax error in the expression, the calling code discovers it
     // before we try to parse it to do substitutions on the parse tree.
-    return new Iterable<String>() {
-      public Iterator<String> iterator() {
-        return new Iterator<String>() {
-          int i = 0;
+    return () -> new Iterator<String>() {
+      int i = 0;
 
-          public void remove() {
-            throw new UnsupportedOperationException();
-          }
+      public void remove() {
+        throw new UnsupportedOperationException();
+      }
 
-          public String next() {
-            switch (i++) {
-            case 0:
-              return buildQuery(expression);
-            case 1:
-              return buildQuery2(expression);
-            default:
-              throw new NoSuchElementException();
-            }
-          }
+      public String next() {
+        switch (i++) {
+        case 0:
+          return buildQuery(expression);
+        case 1:
+          return buildQuery2(expression);
+        default:
+          throw new NoSuchElementException();
+        }
+      }
 
-          public boolean hasNext() {
-            return i < 2;
-          }
-        };
+      public boolean hasNext() {
+        return i < 2;
       }
     };
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/sql/test/SqlTests.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlTests.java b/core/src/test/java/org/apache/calcite/sql/test/SqlTests.java
index d2162de..e0c4bb1 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlTests.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlTests.java
@@ -52,20 +52,14 @@ public abstract class SqlTests {
   /**
    * Checker which allows any type.
    */
-  public static final TypeChecker ANY_TYPE_CHECKER =
-      new TypeChecker() {
-        public void checkType(RelDataType type) {
-        }
-      };
+  public static final TypeChecker ANY_TYPE_CHECKER = type -> {
+  };
 
   /**
    * Checker that allows any number or type of parameters.
    */
-  public static final ParameterChecker ANY_PARAMETER_CHECKER =
-      new ParameterChecker() {
-        public void checkParameters(RelDataType parameterRowType) {
-        }
-      };
+  public static final ParameterChecker ANY_PARAMETER_CHECKER = parameterRowType -> {
+  };
 
   /**
    * Helper function to get the string representation of a RelDataType
@@ -389,13 +383,6 @@ public abstract class SqlTests {
       compareResultSet(resultSet, expected);
     }
   }
-
-  /** Result checker that accepts any result. */
-  public static final ResultChecker ANY_RESULT_CHECKER =
-      new ResultChecker() {
-        public void checkResult(ResultSet result) {
-        }
-      };
 }
 
 // End SqlTests.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/d59b639d/core/src/test/java/org/apache/calcite/sql/type/SqlTypeFactoryTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/type/SqlTypeFactoryTest.java b/core/src/test/java/org/apache/calcite/sql/type/SqlTypeFactoryTest.java
index f3c5209..60e3325 100644
--- a/core/src/test/java/org/apache/calcite/sql/type/SqlTypeFactoryTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/type/SqlTypeFactoryTest.java
@@ -26,7 +26,6 @@ import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
 
-
 /**
  * Test for {@link SqlTypeFactoryImpl}.
  */