calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [43/58] [abbrv] [partial] incubator-calcite git commit: [CALCITE-306] Standardize code style for "import package.*; "
Date Fri, 14 Nov 2014 21:32:51 GMT
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/interpreter/ScanNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/ScanNode.java b/core/src/main/java/org/apache/calcite/interpreter/ScanNode.java
index 778b473..e2bdfd4 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/ScanNode.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/ScanNode.java
@@ -14,27 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.impl.interpreter;
+package org.apache.calcite.interpreter;
 
-import net.hydromatic.linq4j.Enumerable;
-import net.hydromatic.linq4j.Enumerator;
-import net.hydromatic.linq4j.Queryable;
-import net.hydromatic.linq4j.function.Function1;
-
-import net.hydromatic.optiq.DataContext;
-import net.hydromatic.optiq.FilterableTable;
-import net.hydromatic.optiq.ProjectableFilterableTable;
-import net.hydromatic.optiq.QueryableTable;
-import net.hydromatic.optiq.ScannableTable;
-import net.hydromatic.optiq.SchemaPlus;
-import net.hydromatic.optiq.Schemas;
-import net.hydromatic.optiq.runtime.Enumerables;
-
-import org.eigenbase.rel.TableAccessRelBase;
-import org.eigenbase.relopt.RelOptTable;
-import org.eigenbase.rex.RexNode;
-import org.eigenbase.util.ImmutableIntList;
-import org.eigenbase.util.Util;
+import org.apache.calcite.DataContext;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.linq4j.function.Function1;
+import org.apache.calcite.plan.RelOptTable;
+import org.apache.calcite.rel.core.TableScan;
+import org.apache.calcite.rex.RexNode;
+import org.apache.calcite.runtime.Enumerables;
+import org.apache.calcite.schema.FilterableTable;
+import org.apache.calcite.schema.ProjectableFilterableTable;
+import org.apache.calcite.schema.QueryableTable;
+import org.apache.calcite.schema.ScannableTable;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Schemas;
+import org.apache.calcite.util.ImmutableIntList;
+import org.apache.calcite.util.Util;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
@@ -47,16 +45,16 @@ import java.util.List;
 
 /**
  * Interpreter node that implements a
- * {@link org.eigenbase.rel.TableAccessRelBase}.
+ * {@link org.apache.calcite.rel.core.TableScan}.
  */
 public class ScanNode implements Node {
   private final Sink sink;
-  private final TableAccessRelBase rel;
+  private final TableScan rel;
   private final ImmutableList<RexNode> filters;
   private final DataContext root;
   private final int[] projects;
 
-  public ScanNode(Interpreter interpreter, TableAccessRelBase rel,
+  public ScanNode(Interpreter interpreter, TableScan rel,
       ImmutableList<RexNode> filters, ImmutableIntList projects) {
     this.rel = rel;
     this.filters = Preconditions.checkNotNull(filters);
@@ -153,8 +151,7 @@ public class ScanNode implements Node {
     if (scannableTable != null) {
       return Enumerables.toRow(scannableTable.scan(root));
     }
-    throw new AssertionError("cannot convert table " + table
-        + " to iterable");
+    throw new AssertionError("cannot convert table " + table + " to iterable");
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/interpreter/Sink.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/Sink.java b/core/src/main/java/org/apache/calcite/interpreter/Sink.java
index 6a07c1d..adcbac7 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/Sink.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/Sink.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.impl.interpreter;
+package org.apache.calcite.interpreter;
 
 /**
  * Sink to which to send rows.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/interpreter/SortNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/SortNode.java b/core/src/main/java/org/apache/calcite/interpreter/SortNode.java
index 7f0c8a6..e5fb91d 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/SortNode.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/SortNode.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.impl.interpreter;
+package org.apache.calcite.interpreter;
 
-import org.eigenbase.rel.RelFieldCollation;
-import org.eigenbase.rel.SortRel;
-import org.eigenbase.rex.RexLiteral;
+import org.apache.calcite.rel.RelFieldCollation;
+import org.apache.calcite.rel.core.Sort;
+import org.apache.calcite.rex.RexLiteral;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
@@ -32,14 +32,14 @@ import java.util.List;
 
 /**
  * Interpreter node that implements a
- * {@link org.eigenbase.rel.SortRel}.
+ * {@link org.apache.calcite.rel.core.Sort}.
  */
 public class SortNode implements Node {
   private final Source source;
   private final Sink sink;
-  private final SortRel rel;
+  private final Sort rel;
 
-  public SortNode(Interpreter interpreter, SortRel rel) {
+  public SortNode(Interpreter interpreter, Sort rel) {
     this.rel = rel;
     this.source = interpreter.source(rel, 0);
     this.sink = interpreter.sink(rel);
@@ -129,4 +129,4 @@ public class SortNode implements Node {
   }
 }
 
-// End ScanNode.java
+// End SortNode.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/interpreter/Source.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/Source.java b/core/src/main/java/org/apache/calcite/interpreter/Source.java
index 6f67d32..f020343 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/Source.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/Source.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.impl.interpreter;
+package org.apache.calcite.interpreter;
 
 /**
  * Source of rows.

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/interpreter/ValuesNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/ValuesNode.java b/core/src/main/java/org/apache/calcite/interpreter/ValuesNode.java
index e60e797..fe68790 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/ValuesNode.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/ValuesNode.java
@@ -14,22 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.impl.interpreter;
+package org.apache.calcite.interpreter;
 
-import org.eigenbase.rel.ValuesRelBase;
-import org.eigenbase.rex.RexLiteral;
+import org.apache.calcite.rel.core.Values;
+import org.apache.calcite.rex.RexLiteral;
 
 import java.util.List;
 
 /**
- * Interpreter node that implements a {@link ValuesRelBase}.
+ * Interpreter node that implements a
+ * {@link org.apache.calcite.rel.core.Values}.
  */
 public class ValuesNode implements Node {
   private final Sink sink;
-  private final ValuesRelBase rel;
+  private final Values rel;
   private final int fieldCount;
 
-  public ValuesNode(Interpreter interpreter, ValuesRelBase rel) {
+  public ValuesNode(Interpreter interpreter, Values rel) {
     this.rel = rel;
     this.sink = interpreter.sink(rel);
     this.fieldCount = rel.getRowType().getFieldCount();

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/interpreter/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/package-info.java b/core/src/main/java/org/apache/calcite/interpreter/package-info.java
index 712d56e..a0117ce 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/package-info.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/package-info.java
@@ -22,6 +22,6 @@
  * preparation time is less, and so the total prepare + execute time is
  * competitive for queries over small data sets.
  */
-package net.hydromatic.optiq.impl.interpreter;
+package org.apache.calcite.adapter.interpreter;
 
 // End package-info.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteConnection.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteConnection.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteConnection.java
index 402f72d..5301b3b 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteConnection.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteConnection.java
@@ -14,13 +14,12 @@
  * 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.QueryProvider;
-
-import net.hydromatic.optiq.SchemaPlus;
-import net.hydromatic.optiq.config.OptiqConnectionConfig;
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.config.CalciteConnectionConfig;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.schema.SchemaPlus;
 
 import java.sql.Connection;
 import java.sql.SQLException;
@@ -34,11 +33,11 @@ import java.util.Properties;
  * <p>You can start off with an empty connection (no schemas), define one
  * or two schemas, and start querying them.</p>
  *
- * <p>Since an {@code OptiqConnection} implements the linq4j
+ * <p>Since a {@code CalciteConnection} implements the linq4j
  * {@link QueryProvider} interface, you can use a connection to execute
  * expression trees as queries.</p>
  */
-public interface OptiqConnection extends Connection, QueryProvider {
+public interface CalciteConnection extends Connection, QueryProvider {
   /**
    * Returns the root schema.
    *
@@ -76,7 +75,7 @@ public interface OptiqConnection extends Connection, QueryProvider {
   // in java.sql.Connection from JDK 1.7, but declare here to allow other JDKs
   String getSchema() throws SQLException;
 
-  OptiqConnectionConfig config();
+  CalciteConnectionConfig config();
 }
 
-// End OptiqConnection.java
+// End CalciteConnection.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java
index 4e8ee07..769ffe8 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteConnectionImpl.java
@@ -14,41 +14,58 @@
  * 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.Expression;
-import net.hydromatic.linq4j.expressions.Expressions;
-import net.hydromatic.linq4j.function.Function0;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.config.OptiqConnectionConfig;
-import net.hydromatic.optiq.config.OptiqConnectionConfigImpl;
-import net.hydromatic.optiq.impl.AbstractSchema;
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
-import net.hydromatic.optiq.materialize.Lattice;
-import net.hydromatic.optiq.materialize.MaterializationService;
-import net.hydromatic.optiq.prepare.OptiqCatalogReader;
-import net.hydromatic.optiq.runtime.Hook;
-import net.hydromatic.optiq.server.OptiqServer;
-import net.hydromatic.optiq.server.OptiqServerStatement;
-
-import org.eigenbase.reltype.RelDataTypeSystem;
-import org.eigenbase.sql.advise.SqlAdvisor;
-import org.eigenbase.sql.advise.SqlAdvisorValidator;
-import org.eigenbase.sql.fun.SqlStdOperatorTable;
-import org.eigenbase.sql.validate.SqlConformance;
-import org.eigenbase.sql.validate.SqlValidatorWithHints;
-import org.eigenbase.util.Holder;
-
-import com.google.common.collect.*;
+package org.apache.calcite.jdbc;
+
+import org.apache.calcite.DataContext;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.AvaticaConnection;
+import org.apache.calcite.avatica.AvaticaFactory;
+import org.apache.calcite.avatica.AvaticaParameter;
+import org.apache.calcite.avatica.AvaticaPrepareResult;
+import org.apache.calcite.avatica.AvaticaStatement;
+import org.apache.calcite.avatica.Helper;
+import org.apache.calcite.avatica.InternalProperty;
+import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.avatica.UnregisteredDriver;
+import org.apache.calcite.config.CalciteConnectionConfig;
+import org.apache.calcite.config.CalciteConnectionConfigImpl;
+import org.apache.calcite.linq4j.BaseQueryable;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.QueryProvider;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.linq4j.function.Function0;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.linq4j.tree.Expressions;
+import org.apache.calcite.materialize.Lattice;
+import org.apache.calcite.materialize.MaterializationService;
+import org.apache.calcite.prepare.CalciteCatalogReader;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.runtime.Hook;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Schemas;
+import org.apache.calcite.schema.impl.AbstractSchema;
+import org.apache.calcite.server.CalciteServer;
+import org.apache.calcite.server.CalciteServerStatement;
+import org.apache.calcite.sql.advise.SqlAdvisor;
+import org.apache.calcite.sql.advise.SqlAdvisorValidator;
+import org.apache.calcite.sql.fun.SqlStdOperatorTable;
+import org.apache.calcite.sql.validate.SqlConformance;
+import org.apache.calcite.sql.validate.SqlValidatorWithHints;
+import org.apache.calcite.util.BuiltInMethod;
+import org.apache.calcite.util.Holder;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
 
 import java.io.Serializable;
-import java.lang.reflect.*;
-import java.sql.*;
-import java.util.*;
+import java.lang.reflect.Type;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TimeZone;
 
 /**
  * Implementation of JDBC connection
@@ -56,20 +73,20 @@ import java.util.*;
  *
  * <p>Abstract to allow newer versions of JDBC to add methods.</p>
  */
-abstract class OptiqConnectionImpl
+abstract class CalciteConnectionImpl
     extends AvaticaConnection
-    implements OptiqConnection, QueryProvider {
+    implements CalciteConnection, QueryProvider {
   public final JavaTypeFactory typeFactory;
 
-  final OptiqRootSchema rootSchema;
-  final Function0<OptiqPrepare> prepareFactory;
-  final OptiqServer server = new OptiqServerImpl();
+  final CalciteRootSchema rootSchema;
+  final Function0<CalcitePrepare> prepareFactory;
+  final CalciteServer server = new CalciteServerImpl();
 
   // must be package-protected
   static final Trojan TROJAN = createTrojan();
 
   /**
-   * Creates an OptiqConnectionImpl.
+   * Creates a CalciteConnectionImpl.
    *
    * <p>Not public; method is called only from the driver.</p>
    *
@@ -80,11 +97,11 @@ abstract class OptiqConnectionImpl
    * @param rootSchema Root schema, or null
    * @param typeFactory Type factory, or null
    */
-  protected OptiqConnectionImpl(Driver driver, AvaticaFactory factory,
-      String url, Properties info, OptiqRootSchema rootSchema,
+  protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
+      String url, Properties info, CalciteRootSchema rootSchema,
       JavaTypeFactory typeFactory) {
     super(driver, factory, url, info);
-    OptiqConnectionConfig cfg = new OptiqConnectionConfigImpl(info);
+    CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
     this.prepareFactory = driver.prepareFactory;
     if (typeFactory != null) {
       this.typeFactory = typeFactory;
@@ -94,7 +111,7 @@ abstract class OptiqConnectionImpl
       this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
     }
     this.rootSchema =
-        rootSchema != null ? rootSchema : OptiqSchema.createRootSchema(true);
+        rootSchema != null ? rootSchema : CalciteSchema.createRootSchema(true);
 
     this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
     this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
@@ -110,15 +127,15 @@ abstract class OptiqConnectionImpl
     return (MetaImpl) meta;
   }
 
-  public OptiqConnectionConfig config() {
-    return new OptiqConnectionConfigImpl(info);
+  public CalciteConnectionConfig config() {
+    return new CalciteConnectionConfigImpl(info);
   }
 
   /** Called after the constructor has completed and the model has been
    * loaded. */
   void init() {
     final MaterializationService service = MaterializationService.instance();
-    for (OptiqSchema.LatticeEntry e : Schemas.getLatticeEntries(rootSchema)) {
+    for (CalciteSchema.LatticeEntry e : Schemas.getLatticeEntries(rootSchema)) {
       final Lattice lattice = e.getLattice();
       for (Lattice.Tile tile : lattice.computeTiles()) {
         service.defineTile(lattice, tile.bitSet(), tile.measures, e.schema,
@@ -129,8 +146,8 @@ abstract class OptiqConnectionImpl
 
   @Override public AvaticaStatement createStatement(int resultSetType,
       int resultSetConcurrency, int resultSetHoldability) throws SQLException {
-    OptiqStatement statement =
-        (OptiqStatement) super.createStatement(
+    CalciteStatement statement =
+        (CalciteStatement) super.createStatement(
             resultSetType, resultSetConcurrency, resultSetHoldability);
     server.addStatement(statement);
     return statement;
@@ -144,8 +161,8 @@ abstract class OptiqConnectionImpl
     try {
       AvaticaPrepareResult prepareResult =
           parseQuery(sql, new ContextImpl(this), -1);
-      OptiqPreparedStatement statement =
-          (OptiqPreparedStatement) factory.newPreparedStatement(
+      CalcitePreparedStatement statement =
+          (CalcitePreparedStatement) factory.newPreparedStatement(
               this,
               prepareResult,
               resultSetType,
@@ -162,19 +179,19 @@ abstract class OptiqConnectionImpl
     }
   }
 
-  <T> OptiqPrepare.PrepareResult<T> parseQuery(String sql,
-      OptiqPrepare.Context prepareContext, int maxRowCount) {
-    OptiqPrepare.Dummy.push(prepareContext);
+  <T> CalcitePrepare.PrepareResult<T> parseQuery(String sql,
+      CalcitePrepare.Context prepareContext, int maxRowCount) {
+    CalcitePrepare.Dummy.push(prepareContext);
     try {
-      final OptiqPrepare prepare = prepareFactory.apply();
+      final CalcitePrepare prepare = prepareFactory.apply();
       return prepare.prepareSql(prepareContext, sql, null, Object[].class,
           maxRowCount);
     } finally {
-      OptiqPrepare.Dummy.pop(prepareContext);
+      CalcitePrepare.Dummy.pop(prepareContext);
     }
   }
 
-  // OptiqConnection methods
+  // CalciteConnection methods
 
   public SchemaPlus getRootSchema() {
     return rootSchema.plus();
@@ -192,11 +209,11 @@ abstract class OptiqConnectionImpl
 
   public <T> Queryable<T> createQuery(
       Expression expression, Class<T> rowType) {
-    return new OptiqQueryable<T>(this, rowType, expression);
+    return new CalciteQueryable<T>(this, rowType, expression);
   }
 
   public <T> Queryable<T> createQuery(Expression expression, Type rowType) {
-    return new OptiqQueryable<T>(this, rowType, expression);
+    return new CalciteQueryable<T>(this, rowType, expression);
   }
 
   public <T> T execute(Expression expression, Type type) {
@@ -209,8 +226,8 @@ abstract class OptiqConnectionImpl
 
   public <T> Enumerator<T> executeQuery(Queryable<T> queryable) {
     try {
-      OptiqStatement statement = (OptiqStatement) createStatement();
-      OptiqPrepare.PrepareResult<T> enumerable =
+      CalciteStatement statement = (CalciteStatement) createStatement();
+      CalcitePrepare.PrepareResult<T> enumerable =
           statement.prepare(queryable);
       final DataContext dataContext =
           createDataContext(ImmutableMap.<String, Object>of());
@@ -238,28 +255,27 @@ abstract class OptiqConnectionImpl
   }
 
   /** Implementation of Queryable. */
-  static class OptiqQueryable<T>
-      extends BaseQueryable<T> {
-    public OptiqQueryable(
-        OptiqConnection connection, Type elementType, Expression expression) {
+  static class CalciteQueryable<T> extends BaseQueryable<T> {
+    public CalciteQueryable(CalciteConnection connection, Type elementType,
+        Expression expression) {
       super(connection, elementType, expression);
     }
 
-    public OptiqConnection getConnection() {
-      return (OptiqConnection) provider;
+    public CalciteConnection getConnection() {
+      return (CalciteConnection) provider;
     }
   }
 
   /** Implementation of Server. */
-  private static class OptiqServerImpl implements OptiqServer {
-    final List<OptiqServerStatement> statementList =
-        new ArrayList<OptiqServerStatement>();
+  private static class CalciteServerImpl implements CalciteServer {
+    final List<CalciteServerStatement> statementList =
+        new ArrayList<CalciteServerStatement>();
 
-    public void removeStatement(OptiqServerStatement optiqServerStatement) {
-      statementList.add(optiqServerStatement);
+    public void removeStatement(CalciteServerStatement calciteServerStatement) {
+      statementList.add(calciteServerStatement);
     }
 
-    public void addStatement(OptiqServerStatement statement) {
+    public void addStatement(CalciteServerStatement statement) {
       statementList.add(statement);
     }
   }
@@ -274,18 +290,18 @@ abstract class OptiqConnectionImpl
         String name) {
       return Expressions.call(
           DataContext.ROOT,
-          BuiltinMethod.DATA_CONTEXT_GET_ROOT_SCHEMA.method);
+          BuiltInMethod.DATA_CONTEXT_GET_ROOT_SCHEMA.method);
     }
   }
 
   /** Implementation of DataContext. */
   static class DataContextImpl implements DataContext {
     private final ImmutableMap<Object, Object> map;
-    private final OptiqSchema rootSchema;
+    private final CalciteSchema rootSchema;
     private final QueryProvider queryProvider;
     private final JavaTypeFactory typeFactory;
 
-    DataContextImpl(OptiqConnectionImpl connection,
+    DataContextImpl(CalciteConnectionImpl connection,
         Map<String, Object> parameters) {
       this.queryProvider = connection;
       this.typeFactory = connection.getTypeFactory();
@@ -330,7 +346,7 @@ abstract class OptiqConnectionImpl
     }
 
     private SqlAdvisor getSqlAdvisor() {
-      final OptiqConnectionImpl con = (OptiqConnectionImpl) queryProvider;
+      final CalciteConnectionImpl con = (CalciteConnectionImpl) queryProvider;
       final String schemaName = con.getSchema();
       final List<String> schemaPath =
           schemaName == null
@@ -338,7 +354,7 @@ abstract class OptiqConnectionImpl
               : ImmutableList.of(schemaName);
       final SqlValidatorWithHints validator =
           new SqlAdvisorValidator(SqlStdOperatorTable.instance(),
-          new OptiqCatalogReader(rootSchema, con.config().caseSensitive(),
+          new CalciteCatalogReader(rootSchema, con.config().caseSensitive(),
               schemaPath, typeFactory),
           typeFactory, SqlConformance.DEFAULT);
       return new SqlAdvisor(validator);
@@ -358,10 +374,10 @@ abstract class OptiqConnectionImpl
   }
 
   /** Implementation of Context. */
-  static class ContextImpl implements OptiqPrepare.Context {
-    private final OptiqConnectionImpl connection;
+  static class ContextImpl implements CalcitePrepare.Context {
+    private final CalciteConnectionImpl connection;
 
-    public ContextImpl(OptiqConnectionImpl connection) {
+    public ContextImpl(CalciteConnectionImpl connection) {
       this.connection = connection;
     }
 
@@ -369,7 +385,7 @@ abstract class OptiqConnectionImpl
       return connection.typeFactory;
     }
 
-    public OptiqRootSchema getRootSchema() {
+    public CalciteRootSchema getRootSchema() {
       return connection.rootSchema;
     }
 
@@ -380,7 +396,7 @@ abstract class OptiqConnectionImpl
           : ImmutableList.of(schemaName);
     }
 
-    public OptiqConnectionConfig config() {
+    public CalciteConnectionConfig config() {
       return connection.config();
     }
 
@@ -388,9 +404,9 @@ abstract class OptiqConnectionImpl
       return connection.createDataContext(ImmutableMap.<String, Object>of());
     }
 
-    public OptiqPrepare.SparkHandler spark() {
+    public CalcitePrepare.SparkHandler spark() {
       final boolean enable = config().spark();
-      return OptiqPrepare.Dummy.getSparkHandler(enable);
+      return CalcitePrepare.Dummy.getSparkHandler(enable);
     }
   }
 
@@ -416,4 +432,4 @@ abstract class OptiqConnectionImpl
 
 }
 
-// End OptiqConnectionImpl.java
+// End CalciteConnectionImpl.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteFactory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteFactory.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteFactory.java
index cac1678..03f5496 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteFactory.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteFactory.java
@@ -14,24 +14,25 @@
  * 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.avatica.*;
-
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.AvaticaConnection;
+import org.apache.calcite.avatica.AvaticaFactory;
+import org.apache.calcite.avatica.UnregisteredDriver;
 
 import java.util.Properties;
 
 /**
- * Extension of {@link net.hydromatic.avatica.AvaticaFactory}
+ * Extension of {@link org.apache.calcite.avatica.AvaticaFactory}
  * for Calcite.
  */
-public abstract class OptiqFactory implements AvaticaFactory {
+public abstract class CalciteFactory implements AvaticaFactory {
   protected final int major;
   protected final int minor;
 
   /** Creates a JDBC factory with given major/minor version number. */
-  protected OptiqFactory(int major, int minor) {
+  protected CalciteFactory(int major, int minor) {
     this.major = major;
     this.minor = minor;
   }
@@ -55,7 +56,7 @@ public abstract class OptiqFactory implements AvaticaFactory {
   /** Creates a connection with a root schema. */
   public abstract AvaticaConnection newConnection(UnregisteredDriver driver,
       AvaticaFactory factory, String url, Properties info,
-      OptiqRootSchema rootSchema, JavaTypeFactory typeFactory);
+      CalciteRootSchema rootSchema, JavaTypeFactory typeFactory);
 }
 
-// End OptiqFactory.java
+// End CalciteFactory.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc40Factory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc40Factory.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc40Factory.java
index a861b07..3d1404d 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc40Factory.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc40Factory.java
@@ -14,17 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.jdbc;
+package org.apache.calcite.jdbc;
 
 /**
- * Implementation of {@link net.hydromatic.avatica.AvaticaFactory}
+ * Implementation of {@link org.apache.calcite.avatica.AvaticaFactory}
  * for Calcite and JDBC 4.0 (corresponds to JDK 1.6).
  */
-public class OptiqJdbc40Factory extends OptiqJdbc41Factory {
+public class CalciteJdbc40Factory extends CalciteJdbc41Factory {
   /** Creates a factory for JDBC version 4.1. */
-  public OptiqJdbc40Factory() {
+  public CalciteJdbc40Factory() {
     super(4, 0);
   }
 }
 
-// End OptiqJdbc40Factory.java
+// End CalciteJdbc40Factory.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc41Factory.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc41Factory.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc41Factory.java
index b55708f..73efcaa 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc41Factory.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteJdbc41Factory.java
@@ -14,55 +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.optiq.impl.java.JavaTypeFactory;
+package org.apache.calcite.jdbc;
+
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.AvaticaConnection;
+import org.apache.calcite.avatica.AvaticaDatabaseMetaData;
+import org.apache.calcite.avatica.AvaticaFactory;
+import org.apache.calcite.avatica.AvaticaPrepareResult;
+import org.apache.calcite.avatica.AvaticaPreparedStatement;
+import org.apache.calcite.avatica.AvaticaResultSetMetaData;
+import org.apache.calcite.avatica.AvaticaStatement;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.UnregisteredDriver;
 
 import java.io.InputStream;
 import java.io.Reader;
-import java.sql.*;
+import java.sql.NClob;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
 import java.util.List;
 import java.util.Properties;
 import java.util.TimeZone;
 
 /**
- * Implementation of {@link net.hydromatic.avatica.AvaticaFactory}
+ * Implementation of {@link org.apache.calcite.avatica.AvaticaFactory}
  * for Calcite and JDBC 4.1 (corresponds to JDK 1.7).
  */
 @SuppressWarnings("UnusedDeclaration")
-public class OptiqJdbc41Factory extends OptiqFactory {
+public class CalciteJdbc41Factory extends CalciteFactory {
   /** Creates a factory for JDBC version 4.1. */
-  public OptiqJdbc41Factory() {
+  public CalciteJdbc41Factory() {
     this(4, 1);
   }
 
   /** Creates a JDBC factory with given major/minor version number. */
-  protected OptiqJdbc41Factory(int major, int minor) {
+  protected CalciteJdbc41Factory(int major, int minor) {
     super(major, minor);
   }
 
-  public OptiqJdbc41Connection newConnection(UnregisteredDriver driver,
+  public CalciteJdbc41Connection newConnection(UnregisteredDriver driver,
       AvaticaFactory factory, String url, Properties info,
-      OptiqRootSchema rootSchema, JavaTypeFactory typeFactory) {
-    return new OptiqJdbc41Connection(
+      CalciteRootSchema rootSchema, JavaTypeFactory typeFactory) {
+    return new CalciteJdbc41Connection(
         (Driver) driver, factory, url, info, rootSchema, typeFactory);
   }
 
-  public OptiqJdbc41DatabaseMetaData newDatabaseMetaData(
+  public CalciteJdbc41DatabaseMetaData newDatabaseMetaData(
       AvaticaConnection connection) {
-    return new OptiqJdbc41DatabaseMetaData(
-        (OptiqConnectionImpl) connection);
+    return new CalciteJdbc41DatabaseMetaData(
+        (CalciteConnectionImpl) connection);
   }
 
-  public OptiqJdbc41Statement newStatement(
+  public CalciteJdbc41Statement newStatement(
       AvaticaConnection connection,
       int resultSetType,
       int resultSetConcurrency,
       int resultSetHoldability) {
-    return new OptiqJdbc41Statement(
-        (OptiqConnectionImpl) connection, resultSetType, resultSetConcurrency,
+    return new CalciteJdbc41Statement(
+        (CalciteConnectionImpl) connection, resultSetType, resultSetConcurrency,
         resultSetHoldability);
   }
 
@@ -72,20 +83,20 @@ public class OptiqJdbc41Factory extends OptiqFactory {
       int resultSetType,
       int resultSetConcurrency,
       int resultSetHoldability) throws SQLException {
-    return new OptiqJdbc41PreparedStatement(
-        (OptiqConnectionImpl) connection,
-        (OptiqPrepare.PrepareResult) prepareResult, resultSetType,
+    return new CalciteJdbc41PreparedStatement(
+        (CalciteConnectionImpl) connection,
+        (CalcitePrepare.PrepareResult) prepareResult, resultSetType,
         resultSetConcurrency, resultSetHoldability);
   }
 
-  public OptiqResultSet newResultSet(
+  public CalciteResultSet newResultSet(
       AvaticaStatement statement,
       AvaticaPrepareResult prepareResult,
       TimeZone timeZone) {
     final ResultSetMetaData metaData =
         newResultSetMetaData(statement, prepareResult.getColumnList());
-    return new OptiqResultSet(statement,
-        (OptiqPrepare.PrepareResult) prepareResult, metaData, timeZone);
+    return new CalciteResultSet(statement,
+        (CalcitePrepare.PrepareResult) prepareResult, metaData, timeZone);
   }
 
   public ResultSetMetaData newResultSetMetaData(
@@ -96,18 +107,18 @@ public class OptiqJdbc41Factory extends OptiqFactory {
   }
 
   /** Implementation of connection for JDBC 4.1. */
-  private static class OptiqJdbc41Connection extends OptiqConnectionImpl {
-    OptiqJdbc41Connection(Driver driver, AvaticaFactory factory, String url,
-        Properties info, OptiqRootSchema rootSchema,
+  private static class CalciteJdbc41Connection extends CalciteConnectionImpl {
+    CalciteJdbc41Connection(Driver driver, AvaticaFactory factory, String url,
+        Properties info, CalciteRootSchema rootSchema,
         JavaTypeFactory typeFactory) {
       super(driver, factory, url, info, rootSchema, typeFactory);
     }
   }
 
   /** Implementation of statement for JDBC 4.1. */
-  private static class OptiqJdbc41Statement extends OptiqStatement {
-    public OptiqJdbc41Statement(
-        OptiqConnectionImpl connection,
+  private static class CalciteJdbc41Statement extends CalciteStatement {
+    public CalciteJdbc41Statement(
+        CalciteConnectionImpl connection,
         int resultSetType,
         int resultSetConcurrency,
         int resultSetHoldability) {
@@ -117,11 +128,11 @@ public class OptiqJdbc41Factory extends OptiqFactory {
   }
 
   /** Implementation of prepared statement for JDBC 4.1. */
-  private static class OptiqJdbc41PreparedStatement
-      extends OptiqPreparedStatement {
-    OptiqJdbc41PreparedStatement(
-        OptiqConnectionImpl connection,
-        OptiqPrepare.PrepareResult prepareResult,
+  private static class CalciteJdbc41PreparedStatement
+      extends CalcitePreparedStatement {
+    CalciteJdbc41PreparedStatement(
+        CalciteConnectionImpl connection,
+        CalcitePrepare.PrepareResult prepareResult,
         int resultSetType,
         int resultSetConcurrency,
         int resultSetHoldability) throws SQLException {
@@ -239,12 +250,12 @@ public class OptiqJdbc41Factory extends OptiqFactory {
   }
 
   /** Implementation of database metadata for JDBC 4.1. */
-  private static class OptiqJdbc41DatabaseMetaData
+  private static class CalciteJdbc41DatabaseMetaData
       extends AvaticaDatabaseMetaData {
-    OptiqJdbc41DatabaseMetaData(OptiqConnectionImpl connection) {
+    CalciteJdbc41DatabaseMetaData(CalciteConnectionImpl connection) {
       super(connection);
     }
   }
 }
 
-// End OptiqJdbc41Factory.java
+// End CalciteJdbc41Factory.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalcitePrepare.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalcitePrepare.java b/core/src/main/java/org/apache/calcite/jdbc/CalcitePrepare.java
index 2814546..9f17655 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalcitePrepare.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalcitePrepare.java
@@ -14,48 +14,56 @@
  * 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.ClassDeclaration;
-import net.hydromatic.linq4j.function.Function0;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.config.OptiqConnectionConfig;
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
-import net.hydromatic.optiq.prepare.OptiqPrepareImpl;
-import net.hydromatic.optiq.runtime.*;
-
-import org.eigenbase.rel.RelNode;
-import org.eigenbase.relopt.RelOptPlanner;
-import org.eigenbase.relopt.RelOptRule;
-import org.eigenbase.reltype.RelDataType;
-import org.eigenbase.reltype.RelDataTypeFactory;
-import org.eigenbase.sql.SqlNode;
-import org.eigenbase.sql.validate.SqlValidator;
-import org.eigenbase.util.Stacks;
+package org.apache.calcite.jdbc;
+
+import org.apache.calcite.DataContext;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.AvaticaParameter;
+import org.apache.calcite.avatica.AvaticaPrepareResult;
+import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.Cursor;
+import org.apache.calcite.config.CalciteConnectionConfig;
+import org.apache.calcite.linq4j.Enumerable;
+import org.apache.calcite.linq4j.EnumerableDefaults;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.linq4j.function.Function0;
+import org.apache.calcite.linq4j.tree.ClassDeclaration;
+import org.apache.calcite.plan.RelOptPlanner;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.prepare.CalcitePrepareImpl;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.runtime.ArrayEnumeratorCursor;
+import org.apache.calcite.runtime.Bindable;
+import org.apache.calcite.runtime.ObjectEnumeratorCursor;
+import org.apache.calcite.runtime.RecordEnumeratorCursor;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.util.Stacks;
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Type;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 /**
  * API for a service that prepares statements for execution.
  */
-public interface OptiqPrepare {
-  Function0<OptiqPrepare> DEFAULT_FACTORY =
-      new Function0<OptiqPrepare>() {
-        public OptiqPrepare apply() {
-          return new OptiqPrepareImpl();
+public interface CalcitePrepare {
+  Function0<CalcitePrepare> DEFAULT_FACTORY =
+      new Function0<CalcitePrepare>() {
+        public CalcitePrepare apply() {
+          return new CalcitePrepareImpl();
         }
       };
   ThreadLocal<ArrayList<Context>> THREAD_CONTEXT_STACK =
       new ThreadLocal<ArrayList<Context>>() {
-        @Override
-        protected ArrayList<Context> initialValue() {
+        @Override protected ArrayList<Context> initialValue() {
           return new ArrayList<Context>();
         }
       };
@@ -79,11 +87,11 @@ public interface OptiqPrepare {
   interface Context {
     JavaTypeFactory getTypeFactory();
 
-    OptiqRootSchema getRootSchema();
+    CalciteRootSchema getRootSchema();
 
     List<String> getDefaultSchemaPath();
 
-    OptiqConnectionConfig config();
+    CalciteConnectionConfig config();
 
     /** Returns the spark handler. Never null. */
     SparkHandler spark();
@@ -130,9 +138,9 @@ public interface OptiqPrepare {
     private static SparkHandler createHandler() {
       try {
         final Class<?> clazz =
-            Class.forName("net.hydromatic.optiq.impl.spark.SparkHandlerImpl");
+            Class.forName("org.apache.calcite.adapter.spark.SparkHandlerImpl");
         Method method = clazz.getMethod("instance");
-        return (OptiqPrepare.SparkHandler) method.invoke(null);
+        return (CalcitePrepare.SparkHandler) method.invoke(null);
       } catch (ClassNotFoundException e) {
         return new TrivialSparkHandler();
       } catch (IllegalAccessException e) {
@@ -185,13 +193,13 @@ public interface OptiqPrepare {
 
   /** The result of parsing and validating a SQL query. */
   public static class ParseResult {
-    public final OptiqPrepareImpl prepare;
+    public final CalcitePrepareImpl prepare;
     public final String sql; // for debug
     public final SqlNode sqlNode;
     public final RelDataType rowType;
     public final RelDataTypeFactory typeFactory;
 
-    public ParseResult(OptiqPrepareImpl prepare, SqlValidator validator,
+    public ParseResult(CalcitePrepareImpl prepare, SqlValidator validator,
         String sql,
         SqlNode sqlNode, RelDataType rowType) {
       super();
@@ -208,7 +216,7 @@ public interface OptiqPrepare {
   public static class ConvertResult extends ParseResult {
     public final RelNode relNode;
 
-    public ConvertResult(OptiqPrepareImpl prepare, SqlValidator validator,
+    public ConvertResult(CalcitePrepareImpl prepare, SqlValidator validator,
         String sql, SqlNode sqlNode, RelDataType rowType, RelNode relNode) {
       super(prepare, validator, sql, sqlNode, rowType);
       this.relNode = relNode;
@@ -293,4 +301,4 @@ public interface OptiqPrepare {
   }
 }
 
-// End OptiqPrepare.java
+// End CalcitePrepare.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalcitePreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalcitePreparedStatement.java b/core/src/main/java/org/apache/calcite/jdbc/CalcitePreparedStatement.java
index 3c66e92..86e657b 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalcitePreparedStatement.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalcitePreparedStatement.java
@@ -14,35 +14,35 @@
  * 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.avatica.AvaticaPrepareResult;
-import net.hydromatic.avatica.AvaticaPreparedStatement;
+import org.apache.calcite.avatica.AvaticaPrepareResult;
+import org.apache.calcite.avatica.AvaticaPreparedStatement;
+import org.apache.calcite.server.CalciteServerStatement;
 
-import net.hydromatic.optiq.server.OptiqServerStatement;
-
-import java.sql.*;
+import java.sql.SQLException;
 
 /**
  * Implementation of {@link java.sql.PreparedStatement}
  * for the Calcite engine.
  *
  * <p>This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
- * it is instantiated using {@link net.hydromatic.avatica.AvaticaFactory#newPreparedStatement}.</p>
+ * it is instantiated using
+ * {@link org.apache.calcite.avatica.AvaticaFactory#newPreparedStatement}.
  */
-abstract class OptiqPreparedStatement
+abstract class CalcitePreparedStatement
     extends AvaticaPreparedStatement
-    implements OptiqServerStatement {
+    implements CalciteServerStatement {
   /**
-   * Creates an OptiqPreparedStatement.
+   * Creates a CalcitePreparedStatement.
    *
    * @param connection Connection
    * @param prepareResult Result of preparing statement
    *
    * @throws SQLException if database error occurs
    */
-  protected OptiqPreparedStatement(
-      OptiqConnectionImpl connection,
+  protected CalcitePreparedStatement(
+      CalciteConnectionImpl connection,
       AvaticaPrepareResult prepareResult,
       int resultSetType,
       int resultSetConcurrency,
@@ -53,14 +53,13 @@ abstract class OptiqPreparedStatement
         resultSetHoldability);
   }
 
-  @Override
-  public OptiqConnectionImpl getConnection() {
-    return (OptiqConnectionImpl) super.getConnection();
+  @Override public CalciteConnectionImpl getConnection() {
+    return (CalciteConnectionImpl) super.getConnection();
   }
 
-  public OptiqConnectionImpl.ContextImpl createPrepareContext() {
-    return new OptiqConnectionImpl.ContextImpl(getConnection());
+  public CalciteConnectionImpl.ContextImpl createPrepareContext() {
+    return new CalciteConnectionImpl.ContextImpl(getConnection());
   }
 }
 
-// End OptiqPreparedStatement.java
+// End CalcitePreparedStatement.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteResultSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteResultSet.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteResultSet.java
index 347542f..3e16c39 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteResultSet.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteResultSet.java
@@ -14,36 +14,40 @@
  * 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.avatica.*;
-
-import net.hydromatic.linq4j.Enumerator;
-import net.hydromatic.linq4j.Linq4j;
-
-import net.hydromatic.optiq.runtime.*;
+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.Handler;
+import org.apache.calcite.linq4j.Enumerator;
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.runtime.ArrayEnumeratorCursor;
+import org.apache.calcite.runtime.ObjectEnumeratorCursor;
 
 import com.google.common.collect.ImmutableList;
 
-import java.sql.*;
-import java.util.*;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.util.List;
+import java.util.TimeZone;
 
 /**
  * Implementation of {@link ResultSet}
  * for the Calcite engine.
  */
-public class OptiqResultSet extends AvaticaResultSet {
-  OptiqResultSet(
-      AvaticaStatement statement,
-      OptiqPrepare.PrepareResult prepareResult,
-      ResultSetMetaData resultSetMetaData,
-      TimeZone timeZone) {
+public class CalciteResultSet extends AvaticaResultSet {
+  CalciteResultSet(AvaticaStatement statement,
+      CalcitePrepare.PrepareResult prepareResult,
+      ResultSetMetaData resultSetMetaData, TimeZone timeZone) {
     super(statement, prepareResult, resultSetMetaData, timeZone);
   }
 
-  @Override protected OptiqResultSet execute() throws SQLException {
+  @Override protected CalciteResultSet execute() throws SQLException {
     // Call driver's callback. It is permitted to throw a RuntimeException.
-    OptiqConnectionImpl connection = getOptiqConnection();
+    CalciteConnectionImpl connection = getCalciteConnection();
     final boolean autoTemp = connection.config().autoTemp();
     Handler.ResultSink resultSink = null;
     if (autoTemp) {
@@ -52,8 +56,7 @@ public class OptiqResultSet extends AvaticaResultSet {
         }
       };
     }
-    connection.getDriver().handler.onStatementExecute(
-        statement, resultSink);
+    connection.getDriver().handler.onStatementExecute(statement, resultSink);
 
     super.execute();
     return this;
@@ -61,9 +64,9 @@ public class OptiqResultSet extends AvaticaResultSet {
 
   @Override public ResultSet create(ColumnMetaData.AvaticaType elementType,
       Iterable iterable) {
-    final OptiqResultSet resultSet =
-        new OptiqResultSet(statement,
-            (OptiqPrepare.PrepareResult) prepareResult, resultSetMetaData,
+    final CalciteResultSet resultSet =
+        new CalciteResultSet(statement,
+            (CalcitePrepare.PrepareResult) prepareResult, resultSetMetaData,
             localCalendar.getTimeZone());
     final Cursor cursor = resultSet.createCursor(elementType, iterable);
     final List<ColumnMetaData> columnMetaDataList;
@@ -87,14 +90,14 @@ public class OptiqResultSet extends AvaticaResultSet {
   }
 
   // do not make public
-  OptiqPrepare.PrepareResult getPrepareResult() {
-    return (OptiqPrepare.PrepareResult) prepareResult;
+  CalcitePrepare.PrepareResult getPrepareResult() {
+    return (CalcitePrepare.PrepareResult) prepareResult;
   }
 
   // do not make public
-  OptiqConnectionImpl getOptiqConnection() {
-    return (OptiqConnectionImpl) statement.getConnection();
+  CalciteConnectionImpl getCalciteConnection() {
+    return (CalciteConnectionImpl) statement.getConnection();
   }
 }
 
-// End OptiqResultSet.java
+// End CalciteResultSet.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteRootSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteRootSchema.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteRootSchema.java
index 84a6c77..6a22618 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteRootSchema.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteRootSchema.java
@@ -14,18 +14,18 @@
  * 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.optiq.Schema;
+import org.apache.calcite.schema.Schema;
 
 /**
  * Root schema.
  */
-public class OptiqRootSchema extends OptiqSchema {
+public class CalciteRootSchema extends CalciteSchema {
   /** Creates a root schema. */
-  OptiqRootSchema(Schema schema) {
+  CalciteRootSchema(Schema schema) {
     super(null, schema, "");
   }
 }
 
-// End OptiqRootSchema.java
+// End CalciteRootSchema.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteSchema.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteSchema.java
index 83044ce..4b34c3e 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteSchema.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteSchema.java
@@ -14,32 +14,49 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package net.hydromatic.optiq.jdbc;
-
-import net.hydromatic.linq4j.Linq4j;
-import net.hydromatic.linq4j.expressions.Expression;
-
-import net.hydromatic.optiq.*;
-import net.hydromatic.optiq.Table;
-import net.hydromatic.optiq.impl.MaterializedViewTable;
-import net.hydromatic.optiq.impl.StarTable;
-import net.hydromatic.optiq.materialize.Lattice;
-import net.hydromatic.optiq.util.Compatible;
-
-import org.eigenbase.util.Pair;
+package org.apache.calcite.jdbc;
+
+import org.apache.calcite.linq4j.Linq4j;
+import org.apache.calcite.linq4j.tree.Expression;
+import org.apache.calcite.materialize.Lattice;
+import org.apache.calcite.schema.Function;
+import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.calcite.schema.TableMacro;
+import org.apache.calcite.schema.impl.MaterializedViewTable;
+import org.apache.calcite.schema.impl.StarTable;
+import org.apache.calcite.util.Compatible;
+import org.apache.calcite.util.Pair;
 
 import com.google.common.base.Preconditions;
-import com.google.common.cache.*;
-import com.google.common.collect.*;
-
-import java.util.*;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSortedMap;
+import com.google.common.collect.ImmutableSortedSet;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.NavigableSet;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
 
 /**
  * Schema.
  *
  * <p>Wrapper around user-defined schema used internally.</p>
  */
-public class OptiqSchema {
+public class CalciteSchema {
   /** Comparator that compares all strings differently, but if two strings are
    * equal in case-insensitive match they are right next to each other. In a
    * collection sorted on this comparator, we can find case-insensitive matches
@@ -56,7 +73,7 @@ public class OptiqSchema {
         }
       };
 
-  private final OptiqSchema parent;
+  private final CalciteSchema parent;
   public final Schema schema;
   public final String name;
   /** Tables explicitly defined in this schema. Does not include tables in
@@ -71,23 +88,23 @@ public class OptiqSchema {
       new TreeSet<String>(COMPARATOR);
   private final NavigableMap<String, FunctionEntry> nullaryFunctionMap =
       new TreeMap<String, FunctionEntry>(COMPARATOR);
-  private final NavigableMap<String, OptiqSchema> subSchemaMap =
-      new TreeMap<String, OptiqSchema>(COMPARATOR);
+  private final NavigableMap<String, CalciteSchema> subSchemaMap =
+      new TreeMap<String, CalciteSchema>(COMPARATOR);
   private ImmutableList<ImmutableList<String>> path;
   private boolean cache = true;
   private final Cached<SubSchemaCache> implicitSubSchemaCache;
   private final Cached<NavigableSet<String>> implicitTableCache;
   private final Cached<NavigableSet<String>> implicitFunctionCache;
 
-  public OptiqSchema(OptiqSchema parent, final Schema schema, String name) {
+  public CalciteSchema(CalciteSchema parent, final Schema schema, String name) {
     this.parent = parent;
     this.schema = schema;
     this.name = name;
-    assert (parent == null) == (this instanceof OptiqRootSchema);
+    assert (parent == null) == (this instanceof CalciteRootSchema);
     this.implicitSubSchemaCache =
         new AbstractCached<SubSchemaCache>() {
           public SubSchemaCache build() {
-            return new SubSchemaCache(OptiqSchema.this,
+            return new SubSchemaCache(CalciteSchema.this,
                 Compatible.INSTANCE.navigableSet(
                     ImmutableSortedSet.copyOf(COMPARATOR,
                         schema.getSubSchemaNames())));
@@ -114,9 +131,9 @@ public class OptiqSchema {
   /** Creates a root schema. When <code>addMetadataSchema</code> argument is
    * true a "metadata" schema containing definitions of tables, columns etc. is
    * added to root schema. */
-  public static OptiqRootSchema createRootSchema(boolean addMetadataSchema) {
-    OptiqRootSchema rootSchema =
-        new OptiqRootSchema(new OptiqConnectionImpl.RootSchema());
+  public static CalciteRootSchema createRootSchema(boolean addMetadataSchema) {
+    CalciteRootSchema rootSchema =
+        new CalciteRootSchema(new CalciteConnectionImpl.RootSchema());
     if (addMetadataSchema) {
       rootSchema.add("metadata", MetadataSchema.INSTANCE);
     }
@@ -157,10 +174,10 @@ public class OptiqSchema {
     return entry;
   }
 
-  public OptiqRootSchema root() {
-    for (OptiqSchema schema = this;;) {
+  public CalciteRootSchema root() {
+    for (CalciteSchema schema = this;;) {
       if (schema.parent == null) {
-        return (OptiqRootSchema) schema;
+        return (CalciteRootSchema) schema;
       }
       schema = schema.parent;
     }
@@ -172,7 +189,7 @@ public class OptiqSchema {
     if (name != null) {
       list.add(name);
     }
-    for (OptiqSchema s = this; s != null; s = s.parent) {
+    for (CalciteSchema s = this; s != null; s = s.parent) {
       if (s.parent != null || !s.name.equals("")) {
         // Omit the root schema's name from the path if it's the empty string,
         // which it usually is.
@@ -193,11 +210,11 @@ public class OptiqSchema {
     this.cache = cache;
   }
 
-  public final OptiqSchema getSubSchema(String schemaName,
+  public final CalciteSchema getSubSchema(String schemaName,
       boolean caseSensitive) {
     if (caseSensitive) {
       // Check explicit schemas, case-sensitive.
-      final OptiqSchema entry = subSchemaMap.get(schemaName);
+      final CalciteSchema entry = subSchemaMap.get(schemaName);
       if (entry != null) {
         return entry;
       }
@@ -211,7 +228,7 @@ public class OptiqSchema {
     } else {
       // Check explicit schemas, case-insensitive.
       //noinspection LoopStatementThatDoesntLoop
-      for (Map.Entry<String, OptiqSchema> entry
+      for (Map.Entry<String, CalciteSchema> entry
           : find(subSchemaMap, schemaName).entrySet()) {
         return entry.getValue();
       }
@@ -228,10 +245,10 @@ public class OptiqSchema {
   }
 
   /** Adds a child schema of this schema. */
-  public OptiqSchema add(String name, Schema schema) {
-    final OptiqSchema optiqSchema = new OptiqSchema(this, schema, name);
-    subSchemaMap.put(name, optiqSchema);
-    return optiqSchema;
+  public CalciteSchema add(String name, Schema schema) {
+    final CalciteSchema calciteSchema = new CalciteSchema(this, schema, name);
+    subSchemaMap.put(name, calciteSchema);
+    return calciteSchema;
   }
 
   /** Returns a table that materializes the given SQL statement. */
@@ -292,8 +309,8 @@ public class OptiqSchema {
     return new SchemaPlusImpl();
   }
 
-  public static OptiqSchema from(SchemaPlus plus) {
-    return ((SchemaPlusImpl) plus).optiqSchema();
+  public static CalciteSchema from(SchemaPlus plus) {
+    return ((SchemaPlusImpl) plus).calciteSchema();
   }
 
   /** Returns the default path resolving functions from this schema.
@@ -314,14 +331,14 @@ public class OptiqSchema {
   }
 
   /** Returns a collection of sub-schemas, both explicit (defined using
-   * {@link #add(String, net.hydromatic.optiq.Schema)}) and implicit
-   * (defined using {@link net.hydromatic.optiq.Schema#getSubSchemaNames()}
+   * {@link #add(String, org.apache.calcite.schema.Schema)}) and implicit
+   * (defined using {@link org.apache.calcite.schema.Schema#getSubSchemaNames()}
    * and {@link Schema#getSubSchema(String)}). */
-  public NavigableMap<String, OptiqSchema> getSubSchemaMap() {
+  public NavigableMap<String, CalciteSchema> getSubSchemaMap() {
     // Build a map of implicit sub-schemas first, then explicit sub-schemas.
     // If there are implicit and explicit with the same name, explicit wins.
-    final ImmutableSortedMap.Builder<String, OptiqSchema> builder =
-        new ImmutableSortedMap.Builder<String, OptiqSchema>(COMPARATOR);
+    final ImmutableSortedMap.Builder<String, CalciteSchema> builder =
+        new ImmutableSortedMap.Builder<String, CalciteSchema>(COMPARATOR);
     final long now = System.currentTimeMillis();
     final SubSchemaCache subSchemaCache = implicitSubSchemaCache.get(now);
     for (String name : subSchemaCache.names) {
@@ -501,10 +518,10 @@ public class OptiqSchema {
    * <p>The members of a schema must have unique names.
    */
   public abstract static class Entry {
-    public final OptiqSchema schema;
+    public final CalciteSchema schema;
     public final String name;
 
-    public Entry(OptiqSchema schema, String name) {
+    public Entry(CalciteSchema schema, String name) {
       Linq4j.requireNonNull(schema);
       Linq4j.requireNonNull(name);
       this.schema = schema;
@@ -521,7 +538,7 @@ public class OptiqSchema {
   public abstract static class TableEntry extends Entry {
     public final List<String> sqls;
 
-    public TableEntry(OptiqSchema schema, String name,
+    public TableEntry(CalciteSchema schema, String name,
         ImmutableList<String> sqls) {
       super(schema, name);
       this.sqls = Preconditions.checkNotNull(sqls);
@@ -532,7 +549,7 @@ public class OptiqSchema {
 
   /** Membership of a function in a schema. */
   public abstract static class FunctionEntry extends Entry {
-    public FunctionEntry(OptiqSchema schema, String name) {
+    public FunctionEntry(CalciteSchema schema, String name) {
       super(schema, name);
     }
 
@@ -545,7 +562,7 @@ public class OptiqSchema {
 
   /** Membership of a lattice in a schema. */
   public abstract static class LatticeEntry extends Entry {
-    public LatticeEntry(OptiqSchema schema, String name) {
+    public LatticeEntry(CalciteSchema schema, String name) {
       super(schema, name);
     }
 
@@ -554,10 +571,11 @@ public class OptiqSchema {
     public abstract TableEntry getStarTable();
   }
 
-  /** Implementation of {@link SchemaPlus} based on an {@code OptiqSchema}. */
+  /** Implementation of {@link SchemaPlus} based on a
+   * {@link org.apache.calcite.jdbc.CalciteSchema}. */
   private class SchemaPlusImpl implements SchemaPlus {
-    public OptiqSchema optiqSchema() {
-      return OptiqSchema.this;
+    CalciteSchema calciteSchema() {
+      return CalciteSchema.this;
     }
 
     public SchemaPlus getParentSchema() {
@@ -565,7 +583,7 @@ public class OptiqSchema {
     }
 
     public String getName() {
-      return OptiqSchema.this.getName();
+      return CalciteSchema.this.getName();
     }
 
     public boolean isMutable() {
@@ -573,11 +591,11 @@ public class OptiqSchema {
     }
 
     public void setCacheEnabled(boolean cache) {
-      OptiqSchema.this.setCache(cache);
+      CalciteSchema.this.setCache(cache);
     }
 
     public boolean isCacheEnabled() {
-      return OptiqSchema.this.cache;
+      return CalciteSchema.this.cache;
     }
 
     public boolean contentsHaveChangedSince(long lastCheck, long now) {
@@ -589,75 +607,76 @@ public class OptiqSchema {
     }
 
     public Table getTable(String name) {
-      final Pair<String, Table> pair = OptiqSchema.this.getTable(name, true);
+      final Pair<String, Table> pair = CalciteSchema.this.getTable(name, true);
       return pair == null ? null : pair.getValue();
     }
 
     public NavigableSet<String> getTableNames() {
-      return OptiqSchema.this.getTableNames();
+      return CalciteSchema.this.getTableNames();
     }
 
     public Collection<Function> getFunctions(String name) {
-      return OptiqSchema.this.getFunctions(name, true);
+      return CalciteSchema.this.getFunctions(name, true);
     }
 
     public NavigableSet<String> getFunctionNames() {
-      return OptiqSchema.this.getFunctionNames();
+      return CalciteSchema.this.getFunctionNames();
     }
 
     public SchemaPlus getSubSchema(String name) {
-      final OptiqSchema subSchema = OptiqSchema.this.getSubSchema(name, true);
+      final CalciteSchema subSchema =
+          CalciteSchema.this.getSubSchema(name, true);
       return subSchema == null ? null : subSchema.plus();
     }
 
     public Set<String> getSubSchemaNames() {
-      return OptiqSchema.this.getSubSchemaMap().keySet();
+      return CalciteSchema.this.getSubSchemaMap().keySet();
     }
 
     public SchemaPlus add(String name, Schema schema) {
-      final OptiqSchema optiqSchema = OptiqSchema.this.add(name, schema);
-      return optiqSchema.plus();
+      final CalciteSchema calciteSchema = CalciteSchema.this.add(name, schema);
+      return calciteSchema.plus();
     }
 
     public <T> T unwrap(Class<T> clazz) {
       if (clazz.isInstance(this)) {
         return clazz.cast(this);
       }
-      if (clazz.isInstance(OptiqSchema.this)) {
-        return clazz.cast(OptiqSchema.this);
+      if (clazz.isInstance(CalciteSchema.this)) {
+        return clazz.cast(CalciteSchema.this);
       }
-      if (clazz.isInstance(OptiqSchema.this.schema)) {
-        return clazz.cast(OptiqSchema.this.schema);
+      if (clazz.isInstance(CalciteSchema.this.schema)) {
+        return clazz.cast(CalciteSchema.this.schema);
       }
       throw new ClassCastException("not a " + clazz);
     }
 
     public void setPath(ImmutableList<ImmutableList<String>> path) {
-      OptiqSchema.this.path = path;
+      CalciteSchema.this.path = path;
     }
 
     public void add(String name, Table table) {
-      OptiqSchema.this.add(name, table);
+      CalciteSchema.this.add(name, table);
     }
 
-    public void add(String name, net.hydromatic.optiq.Function function) {
-      OptiqSchema.this.add(name, function);
+    public void add(String name, Function function) {
+      CalciteSchema.this.add(name, function);
     }
 
     public void add(String name, Lattice lattice) {
-      OptiqSchema.this.add(name, lattice);
+      CalciteSchema.this.add(name, lattice);
     }
   }
 
   /**
-   * Implementation of {@link net.hydromatic.optiq.jdbc.OptiqSchema.TableEntry}
+   * Implementation of {@link CalciteSchema.TableEntry}
    * where all properties are held in fields.
    */
   public static class TableEntryImpl extends TableEntry {
     private final Table table;
 
     /** Creates a TableEntryImpl. */
-    public TableEntryImpl(OptiqSchema schema, String name, Table table,
+    public TableEntryImpl(CalciteSchema schema, String name, Table table,
         ImmutableList<String> sqls) {
       super(schema, name, sqls);
       assert table != null;
@@ -677,7 +696,7 @@ public class OptiqSchema {
     private final Function function;
 
     /** Creates a FunctionEntryImpl. */
-    public FunctionEntryImpl(OptiqSchema schema, String name,
+    public FunctionEntryImpl(CalciteSchema schema, String name,
         Function function) {
       super(schema, name);
       this.function = function;
@@ -699,10 +718,11 @@ public class OptiqSchema {
    */
   public static class LatticeEntryImpl extends LatticeEntry {
     private final Lattice lattice;
-    private final OptiqSchema.TableEntry starTableEntry;
+    private final CalciteSchema.TableEntry starTableEntry;
 
     /** Creates a LatticeEntryImpl. */
-    public LatticeEntryImpl(OptiqSchema schema, String name, Lattice lattice) {
+    public LatticeEntryImpl(CalciteSchema schema, String name,
+        Lattice lattice) {
       super(schema, name);
       this.lattice = lattice;
 
@@ -732,18 +752,18 @@ public class OptiqSchema {
     /** Creates a new value. */
     T build();
 
-    /** Called when OptiqSchema caching is enabled or disabled. */
+    /** Called when CalciteSchema caching is enabled or disabled. */
     void enable(long now, boolean enabled);
   }
 
-  /** Implementation of {@link net.hydromatic.optiq.jdbc.OptiqSchema.Cached}
-   * that drives from {@link net.hydromatic.optiq.jdbc.OptiqSchema#cache}. */
+  /** Implementation of {@link CalciteSchema.Cached}
+   * that drives from {@link CalciteSchema#cache}. */
   private abstract class AbstractCached<T> implements Cached<T> {
     T t;
     long checked = Long.MIN_VALUE;
 
     public T get(long now) {
-      if (!OptiqSchema.this.cache) {
+      if (!CalciteSchema.this.cache) {
         return build();
       }
       if (checked == Long.MIN_VALUE
@@ -762,32 +782,32 @@ public class OptiqSchema {
     }
   }
 
-  /** Information about the implicit sub-schemas of an {@link OptiqSchema}. */
+  /** Information about the implicit sub-schemas of an {@link CalciteSchema}. */
   private static class SubSchemaCache {
     /** The names of sub-schemas returned from the {@link Schema} SPI. */
     final NavigableSet<String> names;
-    /** Cached {@link net.hydromatic.optiq.jdbc.OptiqSchema} wrappers. It is
+    /** Cached {@link CalciteSchema} wrappers. It is
      * worth caching them because they contain maps of their own sub-objects. */
-    final LoadingCache<String, OptiqSchema> cache;
+    final LoadingCache<String, CalciteSchema> cache;
 
-    private SubSchemaCache(final OptiqSchema optiqSchema,
+    private SubSchemaCache(final CalciteSchema calciteSchema,
         NavigableSet<String> names) {
       this.names = names;
       this.cache = CacheBuilder.newBuilder().build(
-          new CacheLoader<String, OptiqSchema>() {
+          new CacheLoader<String, CalciteSchema>() {
             @SuppressWarnings("NullableProblems")
-            @Override public OptiqSchema load(String schemaName) {
+            @Override public CalciteSchema load(String schemaName) {
               final Schema subSchema =
-                  optiqSchema.schema.getSubSchema(schemaName);
+                  calciteSchema.schema.getSubSchema(schemaName);
               if (subSchema == null) {
                 throw new RuntimeException("sub-schema " + schemaName
                     + " not found");
               }
-              return new OptiqSchema(optiqSchema, subSchema, schemaName);
+              return new CalciteSchema(calciteSchema, subSchema, schemaName);
             }
           });
     }
   }
 }
 
-// End OptiqSchema.java
+// End CalciteSchema.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/CalciteStatement.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteStatement.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteStatement.java
index eb29453..c8f0e17 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteStatement.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteStatement.java
@@ -14,23 +14,22 @@
  * 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.avatica.*;
-
-import net.hydromatic.linq4j.Queryable;
-
-import net.hydromatic.optiq.server.OptiqServerStatement;
+import org.apache.calcite.avatica.AvaticaResultSet;
+import org.apache.calcite.avatica.AvaticaStatement;
+import org.apache.calcite.linq4j.Queryable;
+import org.apache.calcite.server.CalciteServerStatement;
 
 /**
  * Implementation of {@link java.sql.Statement}
  * for the Calcite engine.
  */
-public abstract class OptiqStatement
+public abstract class CalciteStatement
     extends AvaticaStatement
-    implements OptiqServerStatement {
-  OptiqStatement(
-      OptiqConnectionImpl connection,
+    implements CalciteServerStatement {
+  CalciteStatement(
+      CalciteConnectionImpl connection,
       int resultSetType,
       int resultSetConcurrency,
       int resultSetHoldability) {
@@ -40,24 +39,25 @@ public abstract class OptiqStatement
 
   // implement Statement
 
-  @Override public OptiqConnectionImpl getConnection() {
-    return (OptiqConnectionImpl) connection;
+  @Override public CalciteConnectionImpl getConnection() {
+    return (CalciteConnectionImpl) connection;
   }
 
-  public OptiqConnectionImpl.ContextImpl createPrepareContext() {
-    return new OptiqConnectionImpl.ContextImpl(getConnection());
+  public CalciteConnectionImpl.ContextImpl createPrepareContext() {
+    return new CalciteConnectionImpl.ContextImpl(getConnection());
   }
 
-  protected <T> OptiqPrepare.PrepareResult<T> prepare(Queryable<T> queryable) {
-    final OptiqPrepare prepare = getConnection().prepareFactory.apply();
+  protected <T> CalcitePrepare.PrepareResult<T> prepare(
+      Queryable<T> queryable) {
+    final CalcitePrepare prepare = getConnection().prepareFactory.apply();
     return prepare.prepareQueryable(createPrepareContext(), queryable);
   }
 
-  @Override
-  protected void close_() {
+  @Override protected void close_() {
     if (!closed) {
       closed = true;
-      final OptiqConnectionImpl connection1 = (OptiqConnectionImpl) connection;
+      final CalciteConnectionImpl connection1 =
+          (CalciteConnectionImpl) connection;
       connection1.server.removeStatement(this);
       if (openResultSet != null) {
         AvaticaResultSet c = openResultSet;
@@ -71,4 +71,4 @@ public abstract class OptiqStatement
   }
 }
 
-// End OptiqStatement.java
+// End CalciteStatement.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/Driver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/Driver.java b/core/src/main/java/org/apache/calcite/jdbc/Driver.java
index a6a25b3..5997f22 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/Driver.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/Driver.java
@@ -14,19 +14,27 @@
  * 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.function.Function0;
-
-import net.hydromatic.optiq.config.OptiqConnectionProperty;
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
-import net.hydromatic.optiq.model.ModelHandler;
+package org.apache.calcite.jdbc;
+
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.AvaticaConnection;
+import org.apache.calcite.avatica.BuiltInConnectionProperty;
+import org.apache.calcite.avatica.ConnectionProperty;
+import org.apache.calcite.avatica.DriverVersion;
+import org.apache.calcite.avatica.Handler;
+import org.apache.calcite.avatica.HandlerImpl;
+import org.apache.calcite.avatica.UnregisteredDriver;
+import org.apache.calcite.config.CalciteConnectionProperty;
+import org.apache.calcite.linq4j.function.Function0;
+import org.apache.calcite.model.ModelHandler;
 
 import java.io.IOException;
 import java.sql.SQLException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
 
 /**
  * Calcite JDBC driver.
@@ -34,7 +42,7 @@ import java.util.*;
 public class Driver extends UnregisteredDriver {
   public static final String CONNECT_STRING_PREFIX = "jdbc:calcite:";
 
-  final Function0<OptiqPrepare> prepareFactory;
+  final Function0<CalcitePrepare> prepareFactory;
 
   static {
     new Driver().register();
@@ -45,46 +53,42 @@ public class Driver extends UnregisteredDriver {
     this.prepareFactory = createPrepareFactory();
   }
 
-  protected Function0<OptiqPrepare> createPrepareFactory() {
-    return OptiqPrepare.DEFAULT_FACTORY;
+  protected Function0<CalcitePrepare> createPrepareFactory() {
+    return CalcitePrepare.DEFAULT_FACTORY;
   }
 
-  @Override
-  protected String getConnectStringPrefix() {
+  @Override protected String getConnectStringPrefix() {
     return CONNECT_STRING_PREFIX;
   }
 
-  @Override
-  protected String getFactoryClassName(JdbcVersion jdbcVersion) {
+  @Override protected String getFactoryClassName(JdbcVersion jdbcVersion) {
     switch (jdbcVersion) {
     case JDBC_30:
-      return "net.hydromatic.optiq.jdbc.OptiqJdbc3Factory";
+      return "org.apache.calcite.jdbc.CalciteJdbc3Factory";
     case JDBC_40:
-      return "net.hydromatic.optiq.jdbc.OptiqJdbc40Factory";
+      return "org.apache.calcite.jdbc.CalciteJdbc40Factory";
     case JDBC_41:
     default:
-      return "net.hydromatic.optiq.jdbc.OptiqJdbc41Factory";
+      return "org.apache.calcite.jdbc.CalciteJdbc41Factory";
     }
   }
 
   protected DriverVersion createDriverVersion() {
     return DriverVersion.load(
         Driver.class,
-        "net-hydromatic-optiq-jdbc.properties",
+        "org-apache-calcite-jdbc.properties",
         "Calcite JDBC Driver",
         "unknown version",
         "Calcite",
         "unknown version");
   }
 
-  @Override
-  protected Handler createHandler() {
+  @Override protected Handler createHandler() {
     return new HandlerImpl() {
-      @Override
-      public void onConnectionInit(AvaticaConnection connection_)
+      @Override public void onConnectionInit(AvaticaConnection connection_)
           throws SQLException {
-        final OptiqConnectionImpl connection =
-            (OptiqConnectionImpl) connection_;
+        final CalciteConnectionImpl connection =
+            (CalciteConnectionImpl) connection_;
         super.onConnectionInit(connection);
         final String model = connection.config().model();
         if (model != null) {
@@ -99,18 +103,17 @@ public class Driver extends UnregisteredDriver {
     };
   }
 
-  @Override
-  protected Collection<ConnectionProperty> getConnectionProperties() {
+  @Override protected Collection<ConnectionProperty> getConnectionProperties() {
     final List<ConnectionProperty> list = new ArrayList<ConnectionProperty>();
     Collections.addAll(list, BuiltInConnectionProperty.values());
-    Collections.addAll(list, OptiqConnectionProperty.values());
+    Collections.addAll(list, CalciteConnectionProperty.values());
     return list;
   }
 
   /** Creates an internal connection. */
-  OptiqConnection connect(OptiqRootSchema rootSchema,
+  CalciteConnection connect(CalciteRootSchema rootSchema,
       JavaTypeFactory typeFactory) {
-    return (OptiqConnection) ((OptiqFactory) factory)
+    return (CalciteConnection) ((CalciteFactory) factory)
         .newConnection(this, factory, CONNECT_STRING_PREFIX, new Properties(),
             rootSchema, typeFactory);
   }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java b/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
index 0e77a60..350a3ef 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/JavaRecordType.java
@@ -14,10 +14,10 @@
  * 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 org.eigenbase.reltype.RelDataTypeField;
-import org.eigenbase.reltype.RelRecordType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rel.type.RelRecordType;
 
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/a0ba73cd/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java b/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
index 6d173f6..3f3fabb 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java
@@ -14,21 +14,26 @@
  * 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.avatica.ByteString;
-
-import net.hydromatic.linq4j.Ord;
-import net.hydromatic.linq4j.expressions.Primitive;
-import net.hydromatic.linq4j.expressions.Types;
-
-import net.hydromatic.optiq.impl.java.JavaTypeFactory;
-import net.hydromatic.optiq.runtime.Unit;
-
-import org.eigenbase.reltype.*;
-import org.eigenbase.sql.type.*;
-import org.eigenbase.util.Pair;
-import org.eigenbase.util.Util;
+import org.apache.calcite.adapter.java.JavaTypeFactory;
+import org.apache.calcite.avatica.ByteString;
+import org.apache.calcite.linq4j.Ord;
+import org.apache.calcite.linq4j.tree.Primitive;
+import org.apache.calcite.linq4j.tree.Types;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rel.type.RelDataTypeFieldImpl;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.rel.type.RelRecordType;
+import org.apache.calcite.runtime.Unit;
+import org.apache.calcite.sql.type.BasicSqlType;
+import org.apache.calcite.sql.type.IntervalSqlType;
+import org.apache.calcite.sql.type.JavaToSqlTypeConversionRules;
+import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.util.Pair;
+import org.apache.calcite.util.Util;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
@@ -38,7 +43,11 @@ import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.math.BigDecimal;
 import java.sql.Array;
-import java.util.*;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Implementation of {@link JavaTypeFactory}.


Mime
View raw message