calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [42/58] [abbrv] [partial] incubator-calcite git commit: [CALCITE-306] Standardize code style for "import package.*; "
Date Fri, 14 Nov 2014 21:32:50 GMT
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/MetaImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/MetaImpl.java b/core/src/main/java/org/apache/calcite/jdbc/MetaImpl.java
index ce807b7..8448062 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/MetaImpl.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/MetaImpl.java
@@ -14,40 +14,66 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.jdbc;
-
-import net.hydromatic.avatica.*;
-
-import net.hydromatic.linq4j.*;
-import net.hydromatic.linq4j.expressions.*;
-import net.hydromatic.linq4j.function.*;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.Table;
-import net.hydromatic.optiq.impl.AbstractTableQueryable;
-import net.hydromatic.optiq.impl.java.AbstractQueryableTable;
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
-import net.hydromatic.optiq.runtime.*;
-
-import org.eigenbase.reltype.*;
-import org.eigenbase.sql.SqlJdbcFunctionCall;
-import org.eigenbase.sql.parser.SqlParser;
-import org.eigenbase.util.Pair;
-import org.eigenbase.util.Util;
+package org.apache.calcite.jdbc;
+
+import org.apache.calcite.DataContext;
+import org.apache.calcite.adapter.java.AbstractQueryableTable;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.AvaticaParameter;
+import org.apache.calcite.avatica.AvaticaPrepareResult;
+import org.apache.calcite.avatica.AvaticaResultSet;
+import org.apache.calcite.avatica.AvaticaStatement;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.Cursor;
+import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.Ord;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.function.Functions;
+import org.apache.calcite.linq4j.function.Predicate1;
+import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeFactoryImpl;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.runtime.EnumeratorCursor;
+import org.apache.calcite.runtime.FlatLists;
+import org.apache.calcite.runtime.RecordEnumeratorCursor;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.impl.AbstractTableQueryable;
+import org.apache.calcite.sql.SqlJdbcFunctionCall;
+import org.apache.calcite.sql.parser.SqlParser;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.*;
+import com.google.common.base.CaseFormat;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import java.sql.*;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.sql.Types;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 import java.util.regex.Pattern;
 
 /**
  * Helper for implementing the {@code getXxx} methods such as
- * {@link net.hydromatic.avatica.AvaticaDatabaseMetaData#getTables}.
+ * {@link org.apache.calcite.avatica.AvaticaDatabaseMetaData#getTables}.
  */
 public class MetaImpl implements Meta {
   private static final Map<Class, Pair<Integer, String>> MAP =
@@ -74,9 +100,9 @@ public class MetaImpl implements Meta {
 
   static final Driver DRIVER = new Driver();
 
-  final OptiqConnectionImpl connection;
+  final CalciteConnectionImpl connection;
 
-  public MetaImpl(OptiqConnectionImpl connection) {
+  public MetaImpl(CalciteConnectionImpl connection) {
     this.connection = connection;
   }
 
@@ -158,7 +184,9 @@ public class MetaImpl implements Meta {
       if (Modifier.isPublic(field.getModifiers())
           && !Modifier.isStatic(field.getModifiers())) {
         list.add(
-            columnMetaData(Util.camelToUpper(field.getName()),
+            columnMetaData(
+                CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE,
+                    field.getName()),
                 list.size() + 1, field.getType()));
       }
     }
@@ -169,37 +197,36 @@ public class MetaImpl implements Meta {
    * not implemented or which query entities that are not supported (e.g.
    * triggers in Lingual). */
   public static <E> ResultSet createEmptyResultSet(
-      OptiqConnectionImpl connection,
+      CalciteConnectionImpl connection,
       final Class<E> clazz) {
     return createResultSet(connection, ImmutableMap.<String, Object>of(),
         fieldMetaData(clazz),
         new RecordEnumeratorCursor<E>(Linq4j.<E>emptyEnumerator(), clazz));
   }
 
-  private static <E> ResultSet createResultSet(OptiqConnectionImpl connection,
+  private static <E> ResultSet createResultSet(CalciteConnectionImpl connection,
       final Map<String, Object> internalParameters,
       final ColumnMetaData.StructType structType,
       final Cursor cursor) {
     try {
       final AvaticaResultSet resultSet = connection.getFactory().newResultSet(
           connection.createStatement(),
-          new OptiqPrepare.PrepareResult<E>("",
+          new CalcitePrepare.PrepareResult<E>("",
               ImmutableList.<AvaticaParameter>of(), internalParameters, null,
               structType, -1, null, Object.class) {
-            @Override
-            public Cursor createCursor(DataContext dataContext) {
+            @Override public Cursor createCursor(DataContext dataContext) {
               return cursor;
             }
           },
           connection.getTimeZone());
-      return OptiqConnectionImpl.TROJAN.execute(resultSet);
+      return CalciteConnectionImpl.TROJAN.execute(resultSet);
     } catch (SQLException e) {
       throw new RuntimeException(e);
     }
   }
 
   private static ResultSet createResultSet(
-      OptiqConnectionImpl connection,
+      CalciteConnectionImpl connection,
       final Enumerable<?> enumerable,
       final NamedFieldGetter columnGetter) {
     //noinspection unchecked
@@ -334,12 +361,12 @@ public class MetaImpl implements Meta {
     return Linq4j.asEnumerable(
         connection.rootSchema.getSubSchemaMap().values())
         .select(
-            new Function1<OptiqSchema, MetaSchema>() {
-              public MetaSchema apply(OptiqSchema optiqSchema) {
+            new Function1<CalciteSchema, MetaSchema>() {
+              public MetaSchema apply(CalciteSchema calciteSchema) {
                 return new MetaSchema(
-                    optiqSchema,
+                    calciteSchema,
                     connection.getCatalog(),
-                    optiqSchema.getName());
+                    calciteSchema.getName());
               }
             })
         .orderBy(
@@ -363,12 +390,12 @@ public class MetaImpl implements Meta {
   }
 
   Enumerable<MetaTable> tables(final MetaSchema schema) {
-    return Linq4j.asEnumerable(schema.optiqSchema.getTableNames())
+    return Linq4j.asEnumerable(schema.calciteSchema.getTableNames())
         .select(
             new Function1<String, MetaTable>() {
               public MetaTable apply(String name) {
                 final Table table =
-                    schema.optiqSchema.getTable(name, true).getValue();
+                    schema.calciteSchema.getTable(name, true).getValue();
                 return new MetaTable(table,
                     schema.tableCatalog,
                     schema.tableSchem,
@@ -377,7 +404,7 @@ public class MetaImpl implements Meta {
             })
         .concat(
             Linq4j.asEnumerable(
-                schema.optiqSchema.getTablesBasedOnNullaryFunctions()
+                schema.calciteSchema.getTablesBasedOnNullaryFunctions()
                     .entrySet())
                 .select(
                     new Function1<Map.Entry<String, Table>, MetaTable>() {
@@ -405,7 +432,7 @@ public class MetaImpl implements Meta {
 
   public Enumerable<MetaColumn> columns(final MetaTable table) {
     final RelDataType rowType =
-        table.optiqTable.getRowType(connection.typeFactory);
+        table.calciteTable.getRowType(connection.typeFactory);
     return Linq4j.asEnumerable(rowType.getFieldList())
         .select(
             new Function1<RelDataTypeField, MetaColumn>() {
@@ -603,21 +630,22 @@ public class MetaImpl implements Meta {
   }
 
   public Cursor createCursor(AvaticaResultSet resultSet_) {
-    OptiqResultSet resultSet = (OptiqResultSet) resultSet_;
+    CalciteResultSet resultSet = (CalciteResultSet) resultSet_;
     Map<String, Object> map = Maps.newLinkedHashMap();
     final List<Object> parameterValues =
-        OptiqConnectionImpl.TROJAN.getParameterValues(resultSet.getStatement());
+        CalciteConnectionImpl.TROJAN.getParameterValues(
+            resultSet.getStatement());
     for (Ord<Object> o : Ord.zip(parameterValues)) {
       map.put("?" + o.i, o.e);
     }
     map.putAll(resultSet.getPrepareResult().getInternalParameters());
     final DataContext dataContext = connection.createDataContext(map);
-    OptiqPrepare.PrepareResult prepareResult = resultSet.getPrepareResult();
+    CalcitePrepare.PrepareResult prepareResult = resultSet.getPrepareResult();
     return prepareResult.createCursor(dataContext);
   }
 
   public AvaticaPrepareResult prepare(AvaticaStatement statement_, String sql) {
-    OptiqStatement statement = (OptiqStatement) statement_;
+    CalciteStatement statement = (CalciteStatement) statement_;
     int maxRowCount = statement.getMaxRows();
     return connection.parseQuery(sql,
         statement.createPrepareContext(),
@@ -626,14 +654,14 @@ public class MetaImpl implements Meta {
 
   /** A trojan-horse method, subject to change without notice. */
   @VisibleForTesting
-  public static DataContext createDataContext(OptiqConnection connection) {
-    return ((OptiqConnectionImpl) connection)
+  public static DataContext createDataContext(CalciteConnection connection) {
+    return ((CalciteConnectionImpl) connection)
         .createDataContext(ImmutableMap.<String, Object>of());
   }
 
   /** A trojan-horse method, subject to change without notice. */
   @VisibleForTesting
-  public static OptiqConnection connect(OptiqRootSchema schema,
+  public static CalciteConnection connect(CalciteRootSchema schema,
       JavaTypeFactory typeFactory) {
     return DRIVER.connect(schema, typeFactory);
   }
@@ -705,7 +733,7 @@ public class MetaImpl implements Meta {
 
   /** Metadata describing a table. */
   public static class MetaTable implements Named {
-    private final Table optiqTable;
+    private final Table calciteTable;
     public final String tableCat;
     public final String tableSchem;
     public final String tableName;
@@ -717,14 +745,14 @@ public class MetaImpl implements Meta {
     public final String selfReferencingColName = null;
     public final String refGeneration = null;
 
-    public MetaTable(Table optiqTable, String tableCat, String tableSchem,
+    public MetaTable(Table calciteTable, String tableCat, String tableSchem,
         String tableName) {
-      this.optiqTable = optiqTable;
-      assert optiqTable != null;
+      this.calciteTable = calciteTable;
+      assert calciteTable != null;
       this.tableCat = tableCat;
       this.tableSchem = tableSchem;
       this.tableName = tableName;
-      this.tableType = optiqTable.getJdbcTableType().name();
+      this.tableType = calciteTable.getJdbcTableType().name();
     }
 
     public String getName() {
@@ -734,15 +762,15 @@ public class MetaImpl implements Meta {
 
   /** Metadata describing a schema. */
   public static class MetaSchema implements Named {
-    private final OptiqSchema optiqSchema;
+    private final CalciteSchema calciteSchema;
     public final String tableCatalog;
     public final String tableSchem;
 
     public MetaSchema(
-        OptiqSchema optiqSchema,
+        CalciteSchema calciteSchema,
         String tableCatalog,
         String tableSchem) {
-      this.optiqSchema = optiqSchema;
+      this.calciteSchema = calciteSchema;
       this.tableCatalog = tableCatalog;
       this.tableSchem = tableSchem;
     }
@@ -907,7 +935,8 @@ public class MetaImpl implements Meta {
         List<ColumnMetaData> columns, List<Field> fields) {
       for (String name : names) {
         final int index = fields.size();
-        final String fieldName = Util.toCamelCase(name);
+        final String fieldName =
+            CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
         final Field field;
         try {
           field = clazz.getField(fieldName);
@@ -962,8 +991,7 @@ public class MetaImpl implements Meta {
     }
 
     @SuppressWarnings("unchecked")
-    @Override
-    public Class<E> getElementType() {
+    @Override public Class<E> getElementType() {
       return (Class<E>) elementType;
     }
 
@@ -976,7 +1004,7 @@ public class MetaImpl implements Meta {
         @SuppressWarnings("unchecked")
         public Enumerator<T> enumerator() {
           return (Enumerator<T>) MetadataTable.this.enumerator(
-              ((OptiqConnectionImpl) queryProvider).meta());
+              ((CalciteConnectionImpl) queryProvider).meta());
         }
       };
     }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/MetadataSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/MetadataSchema.java b/core/src/main/java/org/apache/calcite/jdbc/MetadataSchema.java
index b7d16dd..03e77aa 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/MetadataSchema.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/MetadataSchema.java
@@ -14,20 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.jdbc;
+package org.apache.calcite.jdbc;
 
-import net.hydromatic.linq4j.Enumerable;
-import net.hydromatic.linq4j.Enumerator;
-import net.hydromatic.linq4j.function.Function1;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.impl.AbstractSchema;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.impl.AbstractSchema;
 
 import com.google.common.collect.ImmutableMap;
 
 import java.util.Map;
 
-import static net.hydromatic.optiq.jdbc.MetaImpl.*;
+import static org.apache.calcite.jdbc.MetaImpl.MetaColumn;
+import static org.apache.calcite.jdbc.MetaImpl.MetaTable;
 
 /** Schema that contains metadata tables such as "TABLES" and "COLUMNS". */
 class MetadataSchema extends AbstractSchema {
@@ -57,8 +58,7 @@ class MetadataSchema extends AbstractSchema {
    * schema called "metadata" that contains tables "TABLES", "COLUMNS" etc. */
   private MetadataSchema() {}
 
-  @Override
-  protected Map<String, Table> getTableMap() {
+  @Override protected Map<String, Table> getTableMap() {
     return TABLE_MAP;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/SqlTimeoutException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/SqlTimeoutException.java b/core/src/main/java/org/apache/calcite/jdbc/SqlTimeoutException.java
index 36f5174..c207842 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/SqlTimeoutException.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/SqlTimeoutException.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.jdbc;
+package org.apache.calcite.jdbc;
 
 import java.sql.SQLException;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/package-info.java b/core/src/main/java/org/apache/calcite/jdbc/package-info.java
index 216ddca..40b3744 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/package-info.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/package-info.java
@@ -18,6 +18,6 @@
 /**
  * JDBC driver for Calcite.
  */
-package net.hydromatic.optiq.jdbc;
+package org.apache.calcite.jdbc;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/Lattice.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/Lattice.java b/core/src/main/java/org/apache/calcite/materialize/Lattice.java
index 24a2146..b4a75c3 100644
--- a/core/src/main/java/org/apache/calcite/materialize/Lattice.java
+++ b/core/src/main/java/org/apache/calcite/materialize/Lattice.java
@@ -14,40 +14,57 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.materialize;
-
-import net.hydromatic.optiq.Schemas;
-import net.hydromatic.optiq.Table;
-import net.hydromatic.optiq.impl.MaterializedViewTable;
-import net.hydromatic.optiq.impl.StarTable;
-import net.hydromatic.optiq.jdbc.OptiqPrepare;
-import net.hydromatic.optiq.jdbc.OptiqSchema;
-import net.hydromatic.optiq.prepare.OptiqPrepareImpl;
-import net.hydromatic.optiq.runtime.Utilities;
-import net.hydromatic.optiq.util.BitSets;
-import net.hydromatic.optiq.util.graph.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.relopt.RelOptUtil;
-import org.eigenbase.rex.*;
-import org.eigenbase.sql.SqlAggFunction;
-import org.eigenbase.sql.SqlDialect;
-import org.eigenbase.sql.SqlJoin;
-import org.eigenbase.sql.SqlKind;
-import org.eigenbase.sql.SqlNode;
-import org.eigenbase.sql.SqlSelect;
-import org.eigenbase.sql.SqlUtil;
-import org.eigenbase.sql.fun.SqlStdOperatorTable;
-import org.eigenbase.sql.validate.SqlValidatorUtil;
-import org.eigenbase.util.Util;
-import org.eigenbase.util.mapping.IntPair;
+package org.apache.calcite.materialize;
+
+import org.apache.calcite.jdbc.CalcitePrepare;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.plan.RelOptUtil;
+import org.apache.calcite.prepare.CalcitePrepareImpl;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.AggregateCall;
+import org.apache.calcite.rel.core.JoinRelType;
+import org.apache.calcite.rel.core.TableScan;
+import org.apache.calcite.rel.logical.LogicalJoin;
+import org.apache.calcite.rel.logical.LogicalProject;
+import org.apache.calcite.rex.RexCall;
+import org.apache.calcite.rex.RexInputRef;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.runtime.Utilities;
+import org.apache.calcite.schema.Schemas;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.impl.MaterializedViewTable;
+import org.apache.calcite.schema.impl.StarTable;
+import org.apache.calcite.sql.SqlAggFunction;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlJoin;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlSelect;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.validate.SqlValidatorUtil;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.Util;
+import org.apache.calcite.util.graph.DefaultDirectedGraph;
+import org.apache.calcite.util.graph.DefaultEdge;
+import org.apache.calcite.util.graph.DirectedGraph;
+import org.apache.calcite.util.graph.TopologicalOrderIterator;
+import org.apache.calcite.util.mapping.IntPair;
 
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.*;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
 
 import java.math.BigInteger;
-import java.util.*;
+import java.util.BitSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * Structure that allows materialized views based upon a star schema to be
@@ -132,7 +149,7 @@ public class Lattice {
   }
 
   /** Creates a Lattice. */
-  public static Lattice create(OptiqSchema schema, String sql, boolean auto) {
+  public static Lattice create(CalciteSchema schema, String sql, boolean auto) {
     return builder(schema, sql).auto(auto).build();
   }
 
@@ -155,15 +172,15 @@ public class Lattice {
 
   private static boolean populate(List<RelNode> nodes, List<int[][]> tempLinks,
       RelNode rel) {
-    if (nodes.isEmpty() && rel instanceof ProjectRel) {
-      return populate(nodes, tempLinks, ((ProjectRel) rel).getChild());
+    if (nodes.isEmpty() && rel instanceof LogicalProject) {
+      return populate(nodes, tempLinks, ((LogicalProject) rel).getInput());
     }
-    if (rel instanceof TableAccessRelBase) {
+    if (rel instanceof TableScan) {
       nodes.add(rel);
       return true;
     }
-    if (rel instanceof JoinRel) {
-      JoinRel join = (JoinRel) rel;
+    if (rel instanceof LogicalJoin) {
+      LogicalJoin join = (LogicalJoin) rel;
       if (join.getJoinType() != JoinRelType.INNER) {
         throw new RuntimeException("only inner join allowed, but got "
             + join.getJoinType());
@@ -229,7 +246,7 @@ public class Lattice {
     if (usedNodes.isEmpty()) {
       usedNodes.add(nodes.get(0));
     }
-    final SqlDialect dialect = SqlDialect.DatabaseProduct.OPTIQ.getDialect();
+    final SqlDialect dialect = SqlDialect.DatabaseProduct.CALCITE.getDialect();
     final StringBuilder buf = new StringBuilder("SELECT ");
     final StringBuilder groupBuf = new StringBuilder("\nGROUP BY ");
     int k = 0;
@@ -300,7 +317,7 @@ public class Lattice {
         }
       }
     }
-    if (OptiqPrepareImpl.DEBUG) {
+    if (CalcitePrepareImpl.DEBUG) {
       System.out.println("Lattice SQL:\n" + buf);
     }
     buf.append(groupBuf);
@@ -324,8 +341,8 @@ public class Lattice {
     return StarTable.of(this, tables);
   }
 
-  public static Builder builder(OptiqSchema optiqSchema, String sql) {
-    return new Builder(optiqSchema, sql);
+  public static Builder builder(CalciteSchema calciteSchema, String sql) {
+    return new Builder(calciteSchema, sql);
   }
 
   public List<Measure> toMeasures(List<AggregateCall> aggCallList) {
@@ -426,14 +443,14 @@ public class Lattice {
    * (the fact table) have precisely one parent and an equi-join
    * condition on one or more pairs of columns linking to it. */
   public static class Node {
-    public final TableAccessRelBase scan;
+    public final TableScan scan;
     public final Node parent;
     public final ImmutableList<IntPair> link;
     public final int startCol;
     public final int endCol;
     public final String alias;
 
-    public Node(TableAccessRelBase scan, Node parent, List<IntPair> link,
+    public Node(TableScan scan, Node parent, List<IntPair> link,
         int startCol, int endCol, String alias) {
       this.scan = Preconditions.checkNotNull(scan);
       this.parent = parent;
@@ -473,10 +490,10 @@ public class Lattice {
 
   /** Measure in a lattice. */
   public static class Measure implements Comparable<Measure> {
-    public final Aggregation agg;
+    public final SqlAggFunction agg;
     public final ImmutableList<Column> args;
 
-    public Measure(Aggregation agg, Iterable<Column> args) {
+    public Measure(SqlAggFunction agg, Iterable<Column> args) {
       this.agg = Preconditions.checkNotNull(agg);
       this.args = ImmutableList.copyOf(args);
     }
@@ -494,7 +511,7 @@ public class Lattice {
     }
 
     @Override public int hashCode() {
-      return Util.hashV(agg, args);
+      return com.google.common.base.Objects.hashCode(agg, args);
     }
 
     @Override public boolean equals(Object obj) {
@@ -581,8 +598,8 @@ public class Lattice {
     private boolean auto = true;
     private Double rowCountEstimate;
 
-    public Builder(OptiqSchema schema, String sql) {
-      OptiqPrepare.ConvertResult parsed =
+    public Builder(CalciteSchema schema, String sql) {
+      CalcitePrepare.ConvertResult parsed =
           Schemas.convert(MaterializedViewTable.MATERIALIZATION_CONNECTION,
               schema, schema.path(null), sql);
 
@@ -626,7 +643,7 @@ public class Lattice {
             throw new RuntimeException("root node must not have relationships: "
                 + relNode);
           }
-          node = new Node((TableAccessRelBase) relNode, null, null,
+          node = new Node((TableScan) relNode, null, null,
               previousColumn, column, aliases.get(nodes.size()));
         } else {
           if (edges.size() != 1) {
@@ -634,7 +651,7 @@ public class Lattice {
                 "child node must have precisely one parent: " + relNode);
           }
           final Edge edge = edges.get(0);
-          node = new Node((TableAccessRelBase) relNode,
+          node = new Node((TableScan) relNode,
               map.get(edge.getSource()), edge.pairs, previousColumn, column,
               aliases.get(nodes.size()));
         }
@@ -693,7 +710,7 @@ public class Lattice {
     }
 
     /** Resolves the arguments of a
-     * {@link net.hydromatic.optiq.model.JsonMeasure}. They must either be null,
+     * {@link org.apache.calcite.model.JsonMeasure}. They must either be null,
      * a string, or a list of strings. Throws if the structure is invalid, or if
      * any of the columns do not exist in the lattice. */
     public ImmutableList<Column> resolveArgs(Object args) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java b/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
index 32193ef..ede840d 100644
--- a/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
+++ b/core/src/main/java/org/apache/calcite/materialize/MaterializationActor.java
@@ -14,17 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.materialize;
+package org.apache.calcite.materialize;
 
-import net.hydromatic.optiq.jdbc.OptiqRootSchema;
-import net.hydromatic.optiq.jdbc.OptiqSchema;
+import org.apache.calcite.jdbc.CalciteRootSchema;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.rel.type.RelDataType;
 
-import org.eigenbase.reltype.RelDataType;
-import org.eigenbase.util.Util;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
 
-import com.google.common.collect.*;
-
-import java.util.*;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Actor that manages the state of materializations in the system.
@@ -49,8 +50,8 @@ class MaterializationActor {
    * same results as executing the query. */
   static class Materialization {
     final MaterializationKey key;
-    final OptiqRootSchema rootSchema;
-    OptiqSchema.TableEntry materializedTable;
+    final CalciteRootSchema rootSchema;
+    CalciteSchema.TableEntry materializedTable;
     final String sql;
     final RelDataType rowType;
 
@@ -66,8 +67,8 @@ class MaterializationActor {
      * @param rowType Row type
      */
     Materialization(MaterializationKey key,
-        OptiqRootSchema rootSchema,
-        OptiqSchema.TableEntry materializedTable,
+        CalciteRootSchema rootSchema,
+        CalciteSchema.TableEntry materializedTable,
         String sql,
         RelDataType rowType) {
       this.key = key;
@@ -82,10 +83,10 @@ class MaterializationActor {
    * schema, with the same path for resolving functions. */
   static class QueryKey {
     final String sql;
-    final OptiqSchema schema;
+    final CalciteSchema schema;
     final List<String> path;
 
-    QueryKey(String sql, OptiqSchema schema, List<String> path) {
+    QueryKey(String sql, CalciteSchema schema, List<String> path) {
       this.sql = sql;
       this.schema = schema;
       this.path = path;
@@ -100,7 +101,7 @@ class MaterializationActor {
     }
 
     @Override public int hashCode() {
-      return Util.hashV(sql, schema, path);
+      return com.google.common.base.Objects.hashCode(sql, schema, path);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/MaterializationKey.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/MaterializationKey.java b/core/src/main/java/org/apache/calcite/materialize/MaterializationKey.java
index af5faaa..c498f48 100644
--- a/core/src/main/java/org/apache/calcite/materialize/MaterializationKey.java
+++ b/core/src/main/java/org/apache/calcite/materialize/MaterializationKey.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.materialize;
+package org.apache.calcite.materialize;
 
 import java.io.Serializable;
 import java.util.UUID;
@@ -28,20 +28,17 @@ import java.util.UUID;
 public class MaterializationKey implements Serializable {
   private final UUID uuid = UUID.randomUUID();
 
-  @Override
-  public int hashCode() {
+  @Override public int hashCode() {
     return uuid.hashCode();
   }
 
-  @Override
-  public boolean equals(Object obj) {
+  @Override public boolean equals(Object obj) {
     return this == obj
         || obj instanceof MaterializationKey
         && uuid.equals(((MaterializationKey) obj).uuid);
   }
 
-  @Override
-  public String toString() {
+  @Override public String toString() {
     return uuid.toString();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java b/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
index 596c7df..a4e289c 100644
--- a/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
+++ b/core/src/main/java/org/apache/calcite/materialize/MaterializationService.java
@@ -14,34 +14,47 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.materialize;
-
-import net.hydromatic.avatica.ColumnMetaData;
-
-import net.hydromatic.linq4j.*;
-import net.hydromatic.linq4j.expressions.Expression;
-import net.hydromatic.linq4j.function.Function1;
-import net.hydromatic.linq4j.function.Functions;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.Table;
-import net.hydromatic.optiq.config.OptiqConnectionProperty;
-import net.hydromatic.optiq.impl.clone.CloneSchema;
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
-import net.hydromatic.optiq.jdbc.*;
-import net.hydromatic.optiq.prepare.Prepare;
-import net.hydromatic.optiq.runtime.Hook;
-import net.hydromatic.optiq.util.BitSets;
-
-import org.eigenbase.reltype.RelDataType;
-import org.eigenbase.reltype.RelDataTypeImpl;
-import org.eigenbase.util.Pair;
-import org.eigenbase.util.Util;
-
-import com.google.common.collect.*;
+package org.apache.calcite.materialize;
+
+import org.apache.calcite.DataContext;
+import org.apache.calcite.adapter.clone.CloneSchema;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.jdbc.CalciteConnection;
+import org.apache.calcite.jdbc.CalcitePrepare;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.jdbc.MetaImpl;
+import org.apache.calcite.linq4j.AbstractQueryable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.linq4j.function.Functions;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.prepare.Prepare;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeImpl;
+import org.apache.calcite.runtime.Hook;
+import org.apache.calcite.schema.Schemas;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.util.BitSets;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 import java.lang.reflect.Type;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.PriorityQueue;
 
 /**
  * Manages the collection of materialized tables known to the system,
@@ -54,16 +67,15 @@ public class MaterializationService {
   /** For testing. */
   private static final ThreadLocal<MaterializationService> THREAD_INSTANCE =
       new ThreadLocal<MaterializationService>() {
-        @Override
-        protected MaterializationService initialValue() {
+        @Override protected MaterializationService initialValue() {
           return new MaterializationService();
         }
       };
 
-  private static final Comparator<Pair<OptiqSchema.TableEntry, TileKey>> C =
-      new Comparator<Pair<OptiqSchema.TableEntry, TileKey>>() {
-        public int compare(Pair<OptiqSchema.TableEntry, TileKey> o0,
-            Pair<OptiqSchema.TableEntry, TileKey> o1) {
+  private static final Comparator<Pair<CalciteSchema.TableEntry, TileKey>> C =
+      new Comparator<Pair<CalciteSchema.TableEntry, TileKey>>() {
+        public int compare(Pair<CalciteSchema.TableEntry, TileKey> o0,
+            Pair<CalciteSchema.TableEntry, TileKey> o1) {
           // We prefer rolling up from the table with the fewest rows.
           final Table t0 = o0.left.getTable();
           final Table t1 = o1.left.getTable();
@@ -83,7 +95,7 @@ public class MaterializationService {
   }
 
   /** Defines a new materialization. Returns its key. */
-  public MaterializationKey defineMaterialization(final OptiqSchema schema,
+  public MaterializationKey defineMaterialization(final CalciteSchema schema,
       TileKey tileKey, String viewSql, List<String> viewSchemaPath,
       final String suggestedTableName, boolean create) {
     final MaterializationActor.QueryKey queryKey =
@@ -96,16 +108,16 @@ public class MaterializationService {
       return null;
     }
 
-    final OptiqConnection connection =
+    final CalciteConnection connection =
         MetaImpl.connect(schema.root(), null);
     final Pair<String, Table> pair = schema.getTableBySql(viewSql);
     Table materializedTable = pair == null ? null : pair.right;
     RelDataType rowType = null;
     if (materializedTable == null) {
-      final ImmutableMap<OptiqConnectionProperty, String> map =
-          ImmutableMap.of(OptiqConnectionProperty.CREATE_MATERIALIZATIONS,
+      final ImmutableMap<CalciteConnectionProperty, String> map =
+          ImmutableMap.of(CalciteConnectionProperty.CREATE_MATERIALIZATIONS,
               "false");
-      final OptiqPrepare.PrepareResult<Object> prepareResult =
+      final CalcitePrepare.PrepareResult<Object> prepareResult =
           Schemas.prepare(connection, schema, viewSchemaPath, viewSql, map);
       rowType = prepareResult.rowType;
       final JavaTypeFactory typeFactory = connection.getTypeFactory();
@@ -146,12 +158,12 @@ public class MaterializationService {
     }
     final String tableName =
         Schemas.uniqueTableName(schema, Util.first(suggestedTableName, "m"));
-    final OptiqSchema.TableEntry tableEntry =
+    final CalciteSchema.TableEntry tableEntry =
         schema.add(tableName, materializedTable, ImmutableList.of(viewSql));
     Hook.CREATE_MATERIALIZATION.run(tableName);
     if (rowType == null) {
       // If we didn't validate the SQL by populating a table, validate it now.
-      final OptiqPrepare.ParseResult parse =
+      final CalcitePrepare.ParseResult parse =
           Schemas.parse(connection, schema, viewSchemaPath, viewSql);
       rowType = parse.rowType;
     }
@@ -169,7 +181,7 @@ public class MaterializationService {
 
   /** Checks whether a materialization is valid, and if so, returns the table
    * where the data are stored. */
-  public OptiqSchema.TableEntry checkValid(MaterializationKey key) {
+  public CalciteSchema.TableEntry checkValid(MaterializationKey key) {
     final MaterializationActor.Materialization materialization =
         actor.keyMap.get(key);
     if (materialization != null) {
@@ -186,8 +198,8 @@ public class MaterializationService {
    * during the recursive SQL that populates a materialization. Otherwise a
    * materialization would try to create itself to populate itself!
    */
-  public Pair<OptiqSchema.TableEntry, TileKey> defineTile(Lattice lattice,
-      BitSet groupSet, List<Lattice.Measure> measureList, OptiqSchema schema,
+  public Pair<CalciteSchema.TableEntry, TileKey> defineTile(Lattice lattice,
+      BitSet groupSet, List<Lattice.Measure> measureList, CalciteSchema schema,
       boolean create, boolean exact) {
     MaterializationKey materializationKey;
     final TileKey tileKey =
@@ -196,7 +208,8 @@ public class MaterializationService {
     // Step 1. Look for an exact match for the tile.
     materializationKey = actor.keyByTile.get(tileKey);
     if (materializationKey != null) {
-      final OptiqSchema.TableEntry tableEntry = checkValid(materializationKey);
+      final CalciteSchema.TableEntry tableEntry =
+          checkValid(materializationKey);
       if (tableEntry != null) {
         return Pair.of(tableEntry, tileKey);
       }
@@ -211,7 +224,7 @@ public class MaterializationService {
       if (allSatisfiable(measureList, tileKey1)) {
         materializationKey = actor.keyByTile.get(tileKey1);
         if (materializationKey != null) {
-          final OptiqSchema.TableEntry tableEntry =
+          final CalciteSchema.TableEntry tableEntry =
               checkValid(materializationKey);
           if (tableEntry != null) {
             return Pair.of(tableEntry, tileKey1);
@@ -232,8 +245,8 @@ public class MaterializationService {
     // TODO: Use a partially-ordered set data structure, so we are not scanning
     // through all tiles.
     if (!exact) {
-      final PriorityQueue<Pair<OptiqSchema.TableEntry, TileKey>> queue =
-          new PriorityQueue<Pair<OptiqSchema.TableEntry, TileKey>>(1, C);
+      final PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>> queue =
+          new PriorityQueue<Pair<CalciteSchema.TableEntry, TileKey>>(1, C);
       for (Map.Entry<TileKey, MaterializationKey> entry
           : actor.keyByTile.entrySet()) {
         final TileKey tileKey2 = entry.getKey();
@@ -242,7 +255,7 @@ public class MaterializationService {
             && !tileKey2.dimensions.equals(groupSet)
             && allSatisfiable(measureList, tileKey2)) {
           materializationKey = entry.getValue();
-          final OptiqSchema.TableEntry tableEntry =
+          final CalciteSchema.TableEntry tableEntry =
               checkValid(materializationKey);
           if (tableEntry != null) {
             queue.add(Pair.of(tableEntry, tileKey2));
@@ -250,8 +263,8 @@ public class MaterializationService {
         }
       }
       if (!queue.isEmpty()) {
-        final Pair<OptiqSchema.TableEntry, TileKey> best = queue.peek();
-        for (Pair<OptiqSchema.TableEntry, TileKey> pair : queue) {
+        final Pair<CalciteSchema.TableEntry, TileKey> best = queue.peek();
+        for (Pair<CalciteSchema.TableEntry, TileKey> pair : queue) {
           System.out.println("table=" + pair.left.path() + " "
               + pair.left.getTable().getStatistic().getRowCount());
         }
@@ -285,7 +298,8 @@ public class MaterializationService {
         defineMaterialization(schema, newTileKey, sql, schema.path(null),
             "m" + groupSet, true);
     if (materializationKey != null) {
-      final OptiqSchema.TableEntry tableEntry = checkValid(materializationKey);
+      final CalciteSchema.TableEntry tableEntry =
+          checkValid(materializationKey);
       if (tableEntry != null) {
         // Obsolete all of the narrower tiles.
         for (TileKey tileKey1 : obsolete) {
@@ -318,7 +332,7 @@ public class MaterializationService {
    * schema. (Each root schema defines a disconnected namespace, with no overlap
    * with the current schema. Especially in a test run, the contents of two
    * root schemas may look similar.) */
-  public List<Prepare.Materialization> query(OptiqSchema rootSchema) {
+  public List<Prepare.Materialization> query(CalciteSchema rootSchema) {
     final List<Prepare.Materialization> list =
         new ArrayList<Prepare.Materialization>();
     for (MaterializationActor.Materialization materialization

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/TileKey.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/TileKey.java b/core/src/main/java/org/apache/calcite/materialize/TileKey.java
index 1ba6136..642edb6 100644
--- a/core/src/main/java/org/apache/calcite/materialize/TileKey.java
+++ b/core/src/main/java/org/apache/calcite/materialize/TileKey.java
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.materialize;
-
-import org.eigenbase.util.Util;
+package org.apache.calcite.materialize;
 
+import com.google.common.base.Objects;
 import com.google.common.collect.ImmutableList;
 
 import java.util.BitSet;
@@ -26,7 +25,7 @@ import java.util.BitSet;
  * lattice that is the basis of a materialization.
  *
  * <p>Holds similar information to a
- * {@link net.hydromatic.optiq.materialize.Lattice.Tile} but a lattice is
+ * {@link org.apache.calcite.materialize.Lattice.Tile} but a lattice is
  * immutable and tiles are not added after their creation. */
 public class TileKey {
   public final Lattice lattice;
@@ -42,7 +41,7 @@ public class TileKey {
   }
 
   @Override public int hashCode() {
-    return Util.hashV(lattice, dimensions);
+    return Objects.hashCode(lattice, dimensions);
   }
 
   @Override public boolean equals(Object obj) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/TileSuggester.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/TileSuggester.java b/core/src/main/java/org/apache/calcite/materialize/TileSuggester.java
index 74ffe27..65095cf 100644
--- a/core/src/main/java/org/apache/calcite/materialize/TileSuggester.java
+++ b/core/src/main/java/org/apache/calcite/materialize/TileSuggester.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.materialize;
+package org.apache.calcite.materialize;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/materialize/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/materialize/package-info.java b/core/src/main/java/org/apache/calcite/materialize/package-info.java
index ebeda47..0aab1ca 100644
--- a/core/src/main/java/org/apache/calcite/materialize/package-info.java
+++ b/core/src/main/java/org/apache/calcite/materialize/package-info.java
@@ -18,10 +18,10 @@
 /**
  * Management of materialized query results.
  *
- * <p>An actor ({@link net.hydromatic.optiq.materialize.MaterializationActor})
+ * <p>An actor ({@link org.apache.calcite.materialize.MaterializationActor})
  * maintains the state of all
  * materializations in the system and is wrapped in a service
- * ({@link net.hydromatic.optiq.materialize.MaterializationService})
+ * ({@link org.apache.calcite.materialize.MaterializationService})
  * for access from other parts of the system.</p>
  *
  * <p>Optimizer rules allow Calcite to rewrite queries using materializations,
@@ -32,6 +32,6 @@
  * instantiating materializations from the intermediate results of queries, and
  * recognize what materializations would be useful based on actual query load.
  */
-package net.hydromatic.optiq.materialize;
+package org.apache.calcite.materialize;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonColumn.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonColumn.java b/core/src/main/java/org/apache/calcite/model/JsonColumn.java
index d6c08dd..2b9a361 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonColumn.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonColumn.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 /**
  * JSON object representing a column.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonCustomSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonCustomSchema.java b/core/src/main/java/org/apache/calcite/model/JsonCustomSchema.java
index 15ebd76..3144d38 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonCustomSchema.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonCustomSchema.java
@@ -14,18 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import java.util.Map;
 
 /**
  * JSON schema element that represents a custom schema.
  *
- * @see net.hydromatic.optiq.model.JsonRoot Description of schema elements
+ * @see org.apache.calcite.model.JsonRoot Description of schema elements
  */
 public class JsonCustomSchema extends JsonMapSchema {
   /** Name of the factory class for this schema. Must implement interface
-   * {@link net.hydromatic.optiq.SchemaFactory} and have a public default
+   * {@link org.apache.calcite.schema.SchemaFactory} and have a public default
    * constructor. */
   public String factory;
 
@@ -36,8 +36,7 @@ public class JsonCustomSchema extends JsonMapSchema {
     handler.visit(this);
   }
 
-  @Override
-  public String toString() {
+  @Override public String toString() {
     return "JsonCustomSchema(name=" + name + ")";
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonCustomTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonCustomTable.java b/core/src/main/java/org/apache/calcite/model/JsonCustomTable.java
index db699a6..07a73d9 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonCustomTable.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonCustomTable.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import java.util.Map;
 
@@ -25,7 +25,7 @@ import java.util.Map;
  */
 public class JsonCustomTable extends JsonTable {
   /** Name of the factory class for this table. Must implement interface
-   * {@link net.hydromatic.optiq.TableFactory} and have a public default
+   * {@link org.apache.calcite.schema.TableFactory} and have a public default
    * constructor. */
   public String factory;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonFunction.java b/core/src/main/java/org/apache/calcite/model/JsonFunction.java
index 5e290b3..5c24ec9 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonFunction.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonFunction.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonJdbcSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonJdbcSchema.java b/core/src/main/java/org/apache/calcite/model/JsonJdbcSchema.java
index eb2e1b6..61923d9 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonJdbcSchema.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonJdbcSchema.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 /**
  * JSON object representing a schema that maps to a JDBC database.
@@ -29,8 +29,7 @@ public class JsonJdbcSchema extends JsonSchema {
   public String jdbcCatalog;
   public String jdbcSchema;
 
-  @Override
-  public void accept(ModelHandler handler) {
+  @Override public void accept(ModelHandler handler) {
     handler.visit(this);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonLattice.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonLattice.java b/core/src/main/java/org/apache/calcite/model/JsonLattice.java
index ec8578d..80974a3 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonLattice.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonLattice.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import com.google.common.collect.Lists;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonMapSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonMapSchema.java b/core/src/main/java/org/apache/calcite/model/JsonMapSchema.java
index 51499cc..e65a211 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonMapSchema.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonMapSchema.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -28,13 +28,11 @@ public class JsonMapSchema extends JsonSchema {
   public final List<JsonTable> tables = new ArrayList<JsonTable>();
   public final List<JsonFunction> functions = new ArrayList<JsonFunction>();
 
-  @Override
-  public void accept(ModelHandler handler) {
+  @Override public void accept(ModelHandler handler) {
     handler.visit(this);
   }
 
-  @Override
-  public void visitChildren(ModelHandler modelHandler) {
+  @Override public void visitChildren(ModelHandler modelHandler) {
     super.visitChildren(modelHandler);
     for (JsonTable jsonTable : tables) {
       jsonTable.accept(modelHandler);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonMaterialization.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonMaterialization.java b/core/src/main/java/org/apache/calcite/model/JsonMaterialization.java
index 17d08fa..59b4828 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonMaterialization.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonMaterialization.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 /**
  * Element that describes how a table is a materialization of a query.
@@ -30,8 +30,7 @@ public class JsonMaterialization {
     handler.visit(this);
   }
 
-  @Override
-  public String toString() {
+  @Override public String toString() {
     return "JsonMaterialization(table=" + table + ", view=" + view + ")";
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonMeasure.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonMeasure.java b/core/src/main/java/org/apache/calcite/model/JsonMeasure.java
index 3499b59..e813c22 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonMeasure.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonMeasure.java
@@ -14,14 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 /**
  * An aggregate function applied to a column (or columns) of a lattice.
  *
- * <p>Occurs in a {@link net.hydromatic.optiq.model.JsonTile},
+ * <p>Occurs in a {@link org.apache.calcite.model.JsonTile},
  * and there is a default list in
- * {@link net.hydromatic.optiq.model.JsonLattice}.
+ * {@link org.apache.calcite.model.JsonLattice}.
  *
  * @see JsonRoot Description of schema elements
  */

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonRoot.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonRoot.java b/core/src/main/java/org/apache/calcite/model/JsonRoot.java
index 52ae471..25e1fa3 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonRoot.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonRoot.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -33,7 +33,7 @@ import java.util.List;
  *     {@link JsonTable} (in collection {@link JsonMapSchema#tables tables})
  *       {@link JsonColumn} (in collection {@link JsonTable#columns columns}
  *     {@link JsonView}
- *     {@link JsonFunction}  (in collection {@link JsonMapSchema#functions functions})
+ *     {@link JsonFunction} (in collection {@link JsonMapSchema#functions functions})
  *     {@link JsonLattice} (in collection {@link JsonSchema#lattices lattices})
  *       {@link JsonMeasure} (in collection {@link JsonLattice#defaultMeasures defaultMeasures})
  *       {@link JsonTile} (in collection {@link JsonLattice#tiles tiles})

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonSchema.java b/core/src/main/java/org/apache/calcite/model/JsonSchema.java
index 0eb2e29..07e326f 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonSchema.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonSchema.java
@@ -14,11 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import com.fasterxml.jackson.annotation.JsonSubTypes;
 import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
 import com.google.common.collect.Lists;
 
 import java.util.List;
@@ -58,10 +57,10 @@ public abstract class JsonSchema {
    * <p>If {@code true}, Calcite will cache the metadata the first time it reads
    * it. This can lead to better performance, especially if name-matching is
    * case-insensitive
-   * (see {@link net.hydromatic.optiq.config.Lex#caseSensitive}).
+   * (see {@link org.apache.calcite.config.Lex#caseSensitive}).
    * However, it also leads to the problem of cache staleness.
    * A particular schema implementation can override the
-   * {@link net.hydromatic.optiq.Schema#contentsHaveChangedSince(long, long)}
+   * {@link org.apache.calcite.schema.Schema#contentsHaveChangedSince(long, long)}
    * method to tell Calcite when it should consider its cache to be out of
    * date.</p>
    *

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonTable.java b/core/src/main/java/org/apache/calcite/model/JsonTable.java
index 0c82f91..c0e7d8d 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonTable.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonTable.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import com.fasterxml.jackson.annotation.JsonSubTypes;
 import com.fasterxml.jackson.annotation.JsonTypeInfo;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonTile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonTile.java b/core/src/main/java/org/apache/calcite/model/JsonTile.java
index f7159f9..aef1d2e 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonTile.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonTile.java
@@ -14,14 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import com.google.common.collect.Lists;
 
 import java.util.List;
 
 /**
- * Materialized view within a {@link net.hydromatic.optiq.model.JsonLattice}.
+ * Materialized view within a {@link org.apache.calcite.model.JsonLattice}.
  *
  * <p>A tile is defined in terms of its dimensionality (the grouping columns,
  * drawn from the lattice) and measures (aggregate functions applied to

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/JsonView.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/JsonView.java b/core/src/main/java/org/apache/calcite/model/JsonView.java
index 4ba9dca..f482765 100644
--- a/core/src/main/java/org/apache/calcite/model/JsonView.java
+++ b/core/src/main/java/org/apache/calcite/model/JsonView.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 import java.util.List;
 
@@ -35,8 +35,7 @@ public class JsonView extends JsonTable {
     handler.visit(this);
   }
 
-  @Override
-  public String toString() {
+  @Override public String toString() {
     return "JsonView(name=" + name + ")";
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/ModelHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/ModelHandler.java b/core/src/main/java/org/apache/calcite/model/ModelHandler.java
index 94c7a96..20a4596 100644
--- a/core/src/main/java/org/apache/calcite/model/ModelHandler.java
+++ b/core/src/main/java/org/apache/calcite/model/ModelHandler.java
@@ -14,44 +14,61 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.model;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.impl.*;
-import net.hydromatic.optiq.impl.jdbc.JdbcSchema;
-import net.hydromatic.optiq.jdbc.OptiqConnection;
-import net.hydromatic.optiq.jdbc.OptiqSchema;
-import net.hydromatic.optiq.materialize.Lattice;
-
-import org.eigenbase.util.Pair;
-import org.eigenbase.util.Util;
+package org.apache.calcite.model;
+
+import org.apache.calcite.adapter.jdbc.JdbcSchema;
+import org.apache.calcite.jdbc.CalciteConnection;
+import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.materialize.Lattice;
+import org.apache.calcite.schema.AggregateFunction;
+import org.apache.calcite.schema.ScalarFunction;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaFactory;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.TableFactory;
+import org.apache.calcite.schema.TableFunction;
+import org.apache.calcite.schema.TableMacro;
+import org.apache.calcite.schema.impl.AbstractSchema;
+import org.apache.calcite.schema.impl.AggregateFunctionImpl;
+import org.apache.calcite.schema.impl.MaterializedViewTable;
+import org.apache.calcite.schema.impl.ScalarFunctionImpl;
+import org.apache.calcite.schema.impl.TableFunctionImpl;
+import org.apache.calcite.schema.impl.TableMacroImpl;
+import org.apache.calcite.schema.impl.ViewTable;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.ObjectMapper;
-
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
 import java.io.File;
 import java.io.IOException;
 import java.sql.SQLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 import javax.sql.DataSource;
 
-import static org.eigenbase.util.Stacks.*;
+import static org.apache.calcite.util.Stacks.peek;
+import static org.apache.calcite.util.Stacks.pop;
+import static org.apache.calcite.util.Stacks.push;
 
 /**
  * Reads a model and creates schema objects accordingly.
  */
 public class ModelHandler {
-  private final OptiqConnection connection;
+  private final CalciteConnection connection;
   private final List<Pair<String, SchemaPlus>> schemaStack =
       new ArrayList<Pair<String, SchemaPlus>>();
   private final String modelUri;
   Lattice.Builder latticeBuilder;
   Lattice.TileBuilder tileBuilder;
 
-  public ModelHandler(OptiqConnection connection, String uri)
+  public ModelHandler(CalciteConnection connection, String uri)
       throws IOException {
     super();
     this.connection = connection;
@@ -194,8 +211,8 @@ public class ModelHandler {
       final Schema schema =
           schemaFactory.create(
               parentSchema, jsonSchema.name, operandMap(jsonSchema.operand));
-      final SchemaPlus optiqSchema = parentSchema.add(jsonSchema.name, schema);
-      populateSchema(jsonSchema, optiqSchema);
+      final SchemaPlus schemaPlus = parentSchema.add(jsonSchema.name, schema);
+      populateSchema(jsonSchema, schemaPlus);
     } catch (Exception e) {
       throw new RuntimeException("Error instantiating " + jsonSchema, e);
     }
@@ -232,8 +249,8 @@ public class ModelHandler {
     JdbcSchema schema =
         JdbcSchema.create(parentSchema, jsonSchema.name, dataSource,
             jsonSchema.jdbcCatalog, jsonSchema.jdbcSchema);
-    final SchemaPlus optiqSchema = parentSchema.add(jsonSchema.name, schema);
-    populateSchema(jsonSchema, optiqSchema);
+    final SchemaPlus schemaPlus = parentSchema.add(jsonSchema.name, schema);
+    populateSchema(jsonSchema, schemaPlus);
   }
 
   public void visit(JsonMaterialization jsonMaterialization) {
@@ -242,12 +259,12 @@ public class ModelHandler {
       if (!schema.isMutable()) {
         throw new RuntimeException(
             "Cannot define materialization; parent schema '"
-            + currentSchemaName()
-            + "' is not a SemiMutableSchema");
+                + currentSchemaName()
+                + "' is not a SemiMutableSchema");
       }
-      OptiqSchema optiqSchema = OptiqSchema.from(schema);
+      CalciteSchema calciteSchema = CalciteSchema.from(schema);
       schema.add(jsonMaterialization.view,
-          MaterializedViewTable.create(optiqSchema,
+          MaterializedViewTable.create(calciteSchema,
               jsonMaterialization.getSql(), null, jsonMaterialization.table));
     } catch (Exception e) {
       throw new RuntimeException("Error instantiating " + jsonMaterialization,
@@ -259,14 +276,13 @@ public class ModelHandler {
     try {
       final SchemaPlus schema = currentSchema();
       if (!schema.isMutable()) {
-        throw new RuntimeException(
-            "Cannot define lattice; parent schema '"
+        throw new RuntimeException("Cannot define lattice; parent schema '"
             + currentSchemaName()
             + "' is not a SemiMutableSchema");
       }
-      OptiqSchema optiqSchema = OptiqSchema.from(schema);
+      CalciteSchema calciteSchema = CalciteSchema.from(schema);
       Lattice.Builder latticeBuilder =
-          Lattice.builder(optiqSchema, jsonLattice.getSql())
+          Lattice.builder(calciteSchema, jsonLattice.getSql())
               .auto(jsonLattice.auto)
               .algorithm(jsonLattice.algorithm);
       if (jsonLattice.rowCountEstimate != null) {
@@ -333,9 +349,8 @@ public class ModelHandler {
   private SchemaPlus currentMutableSchema(String elementType) {
     final SchemaPlus schema = currentSchema();
     if (!schema.isMutable()) {
-      throw new RuntimeException(
-          "Cannot define " + elementType + "; parent schema '"
-          + schema.getName() + "' is not mutable");
+      throw new RuntimeException("Cannot define " + elementType
+          + "; parent schema '" + schema.getName() + "' is not mutable");
     }
     return schema;
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/model/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/model/package-info.java b/core/src/main/java/org/apache/calcite/model/package-info.java
index c44d6fe..38a08a5 100644
--- a/core/src/main/java/org/apache/calcite/model/package-info.java
+++ b/core/src/main/java/org/apache/calcite/model/package-info.java
@@ -21,19 +21,19 @@
  * <p>Models are specified using a <code>model=&lt;uri&gt;</code> parameter on
  * the JDBC connect string. Calcite loads the model while initializing the
  * connection. It first parses the JSON, then uses a
- * {@link net.hydromatic.optiq.model.ModelHandler} as visitor over the parse
+ * {@link org.apache.calcite.model.ModelHandler} as visitor over the parse
  * tree.</p>
  *
  * <p>There are standard implementations of schema and table, but the user can
  * provide their own by implementing the
- * {@link net.hydromatic.optiq.SchemaFactory}
- * or {@link net.hydromatic.optiq.TableFactory}
+ * {@link org.apache.calcite.schema.SchemaFactory}
+ * or {@link org.apache.calcite.schema.TableFactory}
  * interfaces and including a custom schema in the model.</p>
  *
  * <p>There are several examples of schemas in the
  * <a href="https://github.com/julianhyde/blog/master/optiq-csv/TUTORIAL.md">optiq-csv
  * tutorial</a>.
  */
-package net.hydromatic.optiq.model;
+package org.apache.calcite.model;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/package-info.java b/core/src/main/java/org/apache/calcite/package-info.java
index 0afdc3f..87ef21f 100644
--- a/core/src/main/java/org/apache/calcite/package-info.java
+++ b/core/src/main/java/org/apache/calcite/package-info.java
@@ -18,6 +18,6 @@
 /**
  * Main package for Calcite, the dynamic data management platform.
  */
-package net.hydromatic.optiq;
+package org.apache.calcite;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java b/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
index 9823b74..b25c28c 100644
--- a/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
+++ b/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
@@ -14,22 +14,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import java.util.*;
-import java.util.logging.*;
-import java.util.regex.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.metadata.*;
-import org.eigenbase.relopt.volcano.RelSubset;
-import org.eigenbase.util.*;
-
-import static org.eigenbase.util.Static.RESOURCE;
+import org.apache.calcite.plan.volcano.RelSubset;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.metadata.RelMetadataProvider;
+import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.util.CancelFlag;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+
+import static org.apache.calcite.util.Static.RESOURCE;
+
 
 /**
  * Abstract base for implementations of the {@link RelOptPlanner} interface.
@@ -146,8 +153,7 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {
         // This rule has the same description as one previously
         // registered, yet it is not equal. You may need to fix the
         // rule's equals and hashCode methods.
-        throw new AssertionError(
-            "Rule's description should be unique; "
+        throw new AssertionError("Rule's description should be unique; "
             + "existing rule=" + existingRule + "; new rule=" + rule);
       }
     }
@@ -293,8 +299,7 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {
     assert ruleCall.getRule().matches(ruleCall);
     if (isRuleExcluded(ruleCall.getRule())) {
       if (LOGGER.isLoggable(Level.FINE)) {
-        LOGGER.fine(
-            "call#" + ruleCall.id
+        LOGGER.fine("call#" + ruleCall.id
             + ": Rule [" + ruleCall.getRule() + "] not fired"
             + " due to exclusion filter");
       }
@@ -344,8 +349,7 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {
       RelNode newRel,
       boolean before) {
     if (before && LOGGER.isLoggable(Level.FINE)) {
-      LOGGER.fine(
-          "call#" + ruleCall.id
+      LOGGER.fine("call#" + ruleCall.id
           + ": Rule " + ruleCall.getRule() + " arguments "
           + Arrays.toString(ruleCall.rels) + " produced "
           + newRel);

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/CommonRelSubExprRule.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/CommonRelSubExprRule.java b/core/src/main/java/org/apache/calcite/plan/CommonRelSubExprRule.java
index 9133ed2..7886ad2 100644
--- a/core/src/main/java/org/apache/calcite/plan/CommonRelSubExprRule.java
+++ b/core/src/main/java/org/apache/calcite/plan/CommonRelSubExprRule.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/Context.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/Context.java b/core/src/main/java/org/apache/calcite/plan/Context.java
index 093cf52..3537d98 100644
--- a/core/src/main/java/org/apache/calcite/plan/Context.java
+++ b/core/src/main/java/org/apache/calcite/plan/Context.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
 /**
  * Provides library users a way to store data within the planner session and
@@ -31,3 +31,5 @@ public interface Context {
   <T> T unwrap(Class<T> clazz);
 
 }
+
+// End Context.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/Contexts.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/Contexts.java b/core/src/main/java/org/apache/calcite/plan/Contexts.java
index 54dddaa..e2fa408 100644
--- a/core/src/main/java/org/apache/calcite/plan/Contexts.java
+++ b/core/src/main/java/org/apache/calcite/plan/Contexts.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import net.hydromatic.optiq.config.OptiqConnectionConfig;
+import org.apache.calcite.config.CalciteConnectionConfig;
 
 /**
  * Utilities for {@link Context}.
@@ -27,8 +27,8 @@ public class Contexts {
   private Contexts() {}
 
   /** Returns a context that contains a
-   * {@link net.hydromatic.optiq.config.OptiqConnectionConfig}. */
-  public static Context withConfig(OptiqConnectionConfig config) {
+   * {@link org.apache.calcite.config.CalciteConnectionConfig}. */
+  public static Context withConfig(CalciteConnectionConfig config) {
     return new ConfigContext(config);
   }
 
@@ -38,11 +38,11 @@ public class Contexts {
   }
 
   /** Context that contains a
-   * {@link net.hydromatic.optiq.config.OptiqConnectionConfig}. */
+   * {@link org.apache.calcite.config.CalciteConnectionConfig}. */
   private static class ConfigContext implements Context {
-    private OptiqConnectionConfig config;
+    private CalciteConnectionConfig config;
 
-    public ConfigContext(OptiqConnectionConfig config) {
+    public ConfigContext(CalciteConnectionConfig config) {
       this.config = config;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/Convention.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/Convention.java b/core/src/main/java/org/apache/calcite/plan/Convention.java
index d1894d3..dbd1a5c 100644
--- a/core/src/main/java/org/apache/calcite/plan/Convention.java
+++ b/core/src/main/java/org/apache/calcite/plan/Convention.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import org.eigenbase.rel.RelNode;
+import org.apache.calcite.rel.RelNode;
 
 /**
  * Calling convention trait.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/ConventionTraitDef.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/ConventionTraitDef.java b/core/src/main/java/org/apache/calcite/plan/ConventionTraitDef.java
index 514a2f5..9de4762 100644
--- a/core/src/main/java/org/apache/calcite/plan/ConventionTraitDef.java
+++ b/core/src/main/java/org/apache/calcite/plan/ConventionTraitDef.java
@@ -14,20 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.convert.*;
-import org.eigenbase.util.Pair;
-import org.eigenbase.util.Util;
-
-import net.hydromatic.optiq.util.graph.*;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.convert.ConverterRule;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
+import org.apache.calcite.util.graph.DefaultDirectedGraph;
+import org.apache.calcite.util.graph.DefaultEdge;
+import org.apache.calcite.util.graph.DirectedGraph;
+import org.apache.calcite.util.graph.Graphs;
 
 import com.google.common.collect.HashMultimap;
 import com.google.common.collect.Multimap;
 
+import java.util.List;
+import java.util.WeakHashMap;
+
 /**
  * Definition of the the convention trait.
  * A new set of conversion information is created for
@@ -146,8 +149,7 @@ public class ConventionTraitDef extends RelTraitDef<Convention> {
                   converted, previous, arc,
                   conversionData.mapArcToConverterRule);
           if (converted == null) {
-            throw Util.newInternal(
-                "Converter from " + previous
+            throw Util.newInternal("Converter from " + previous
                 + " to " + arc
                 + " guaranteed that it could convert any relexp");
           }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/MulticastRelOptListener.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/MulticastRelOptListener.java b/core/src/main/java/org/apache/calcite/plan/MulticastRelOptListener.java
index 549e44f..9b2bcc0 100644
--- a/core/src/main/java/org/apache/calcite/plan/MulticastRelOptListener.java
+++ b/core/src/main/java/org/apache/calcite/plan/MulticastRelOptListener.java
@@ -14,9 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * MulticastRelOptListener implements the {@link RelOptListener} interface by

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelImplementor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelImplementor.java b/core/src/main/java/org/apache/calcite/plan/RelImplementor.java
index ad41d88..6ae9d6c 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelImplementor.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelImplementor.java
@@ -14,15 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import org.eigenbase.rel.*;
+import org.apache.calcite.rel.RelNode;
 
 /**
- * Callback used to hold state while converting a tree of {@link RelNode
- * relational expressions} into a plan. Calling conventions typically have their
- * own protocol for walking over a tree, and correspondingly have their own
- * implementors, which are subclasses of <code>RelImplementor</code>.
+ * Callback used to hold state while converting a tree of
+ * {@link RelNode relational expressions} into a plan. Calling
+ * conventions typically have their own protocol for walking over a
+ * tree, and correspondingly have their own implementors, which are
+ * subclasses of <code>RelImplementor</code>.
  */
 public interface RelImplementor {
   //~ Methods ----------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelOptAbstractTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptAbstractTable.java b/core/src/main/java/org/apache/calcite/plan/RelOptAbstractTable.java
index 9efe276..5496477 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptAbstractTable.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptAbstractTable.java
@@ -14,17 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import java.util.*;
-
-import org.eigenbase.rel.*;
-import org.eigenbase.reltype.*;
-
-import net.hydromatic.linq4j.expressions.Expression;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.rel.RelCollation;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.logical.LogicalTableScan;
+import org.apache.calcite.rel.type.RelDataType;
 
 import com.google.common.collect.ImmutableList;
 
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * Partial implementation of {@link RelOptTable}.
  */
@@ -85,7 +88,7 @@ public abstract class RelOptAbstractTable implements RelOptTable {
   }
 
   public RelNode toRel(ToRelContext context) {
-    return new TableAccessRel(context.getCluster(), this);
+    return new LogicalTableScan(context.getCluster(), this);
   }
 
   public Expression getExpression(Class clazz) {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelOptCluster.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptCluster.java b/core/src/main/java/org/apache/calcite/plan/RelOptCluster.java
index 30688a6..d1171ab 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptCluster.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptCluster.java
@@ -14,19 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import org.eigenbase.rel.*;
-import org.eigenbase.rel.metadata.*;
-import org.eigenbase.reltype.*;
-import org.eigenbase.rex.*;
+import org.apache.calcite.rel.metadata.DefaultRelMetadataProvider;
+import org.apache.calcite.rel.metadata.MetadataFactory;
+import org.apache.calcite.rel.metadata.MetadataFactoryImpl;
+import org.apache.calcite.rel.metadata.RelMetadataProvider;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rex.RexBuilder;
+import org.apache.calcite.rex.RexNode;
 
 /**
- * A <code>RelOptCluster</code> is a collection of {@link RelNode relational
- * expressions} which have the same environment.
- *
- * <p>See the comment against <code>net.sf.saffron.oj.xlat.QueryInfo</code> on
- * why you should put fields in that class, not this one.</p>
+ * An environment for related relational expressions during the
+ * optimization of a query.
  */
 public class RelOptCluster {
   //~ Instance fields --------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelOptConnection.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptConnection.java b/core/src/main/java/org/apache/calcite/plan/RelOptConnection.java
index 39b1800..0005e62 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptConnection.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptConnection.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
 /**
  * The planner's view of a connection to a database.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelOptCost.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptCost.java b/core/src/main/java/org/apache/calcite/plan/RelOptCost.java
index 50ab422..1e19a72 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptCost.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptCost.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
 /**
  * RelOptCost defines an interface for optimizer cost in terms of number of rows
@@ -31,8 +31,8 @@ public interface RelOptCost {
 
   /**
    * @return number of rows processed; this should not be confused with the
-   * row count produced by a relational expression ({@link
-   * org.eigenbase.rel.RelNode#getRows})
+   * row count produced by a relational expression
+   * ({@link org.apache.calcite.rel.RelNode#getRows})
    */
   double getRows();
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelOptCostFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptCostFactory.java b/core/src/main/java/org/apache/calcite/plan/RelOptCostFactory.java
index 9486dc3..cb3ec0b 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptCostFactory.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptCostFactory.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
 /**
  * Cost model for query planning.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java b/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
index 81dded2..7c5aeca 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptCostImpl.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.eigenbase.relopt;
+package org.apache.calcite.plan;
 
-import org.eigenbase.util.Util;
+import org.apache.calcite.util.Util;
 
 /**
  * RelOptCostImpl provides a default implementation for the {@link RelOptCost}
@@ -69,8 +69,7 @@ public class RelOptCostImpl implements RelOptCost {
     return getRows() < other.getRows();
   }
 
-  @Override
-  public int hashCode() {
+  @Override public int hashCode() {
     return Util.hashCode(getRows());
   }
 


Mime
View raw message