Repository: calcite
Updated Branches:
  refs/heads/master c2ae9f0d5 -> 23eb11eb3


[CALCITE-2484] Move dynamic tests to a separate class like 
SqlValidatorDynamicTest, and  avoid reuse of MockCatalogReaderDynamic


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/23eb11eb
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/23eb11eb
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/23eb11eb

Branch: refs/heads/master
Commit: 23eb11eb3b59e496cdc865926537a76fff53c165
Parents: c2ae9f0
Author: Vladimir Sitnikov <sitnikov.vladi...@gmail.com>
Authored: Wed Sep 5 22:42:05 2018 +0300
Committer: Vladimir Sitnikov <sitnikov.vladi...@gmail.com>
Committed: Wed Sep 5 22:42:05 2018 +0300

----------------------------------------------------------------------
 .../apache/calcite/sql/test/SqlAdvisorTest.java |   1 -
 .../apache/calcite/test/RelOptRulesTest.java    |   4 +-
 .../calcite/test/SqlToRelConverterTest.java     |   3 +-
 .../apache/calcite/test/SqlToRelTestBase.java   |  59 ++------
 .../calcite/test/SqlValidatorDynamicTest.java   | 150 +++++++++++++++++++
 .../apache/calcite/test/SqlValidatorTest.java   |  38 -----
 .../test/catalog/MockCatalogReaderDynamic.java  |  74 +++++++++
 .../test/catalog/MockCatalogReaderSimple.java   |  14 --
 8 files changed, 240 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java 
b/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
index 148d22e..ebee877 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlAdvisorTest.java
@@ -97,7 +97,6 @@ public class SqlAdvisorTest extends SqlValidatorTestCase {
   private static final List<String> SCHEMAS =
       Arrays.asList(
           "CATALOG(CATALOG)",
-          "SCHEMA(CATALOG.DYNAMIC)",
           "SCHEMA(CATALOG.SALES)",
           "SCHEMA(CATALOG.STRUCT)",
           "SCHEMA(CATALOG.CUSTOMER)",

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java 
b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index 11bf234..38038a4 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -1978,7 +1978,7 @@ public class RelOptRulesTest extends RelOptTestBase {
 
   private void checkPlanning(String query) throws Exception {
     final Tester tester1 = tester.withCatalogReaderFactory(
-        typeFactory -> new MockCatalogReader(typeFactory, true) {
+        (typeFactory, caseSensitive) -> new MockCatalogReader(typeFactory, 
caseSensitive) {
           @Override public MockCatalogReader init() {
             // CREATE SCHEMA abc;
             // CREATE TABLE a(a INT);
@@ -1997,7 +1997,7 @@ public class RelOptRulesTest extends RelOptTestBase {
             return this;
           }
           // CHECKSTYLE: IGNORE 1
-        }.init());
+        });
     HepProgram program = new HepProgramBuilder()
         .addMatchOrder(HepMatchOrder.BOTTOM_UP)
         .addRuleInstance(ProjectRemoveRule.INSTANCE)

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
index dc88b36..a7496e9 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -2652,8 +2652,7 @@ public class SqlToRelConverterTest extends 
SqlToRelTestBase {
   }
 
   private Tester getExtendedTester() {
-    return tester.withCatalogReaderFactory(typeFactory ->
-        new MockCatalogReaderExtended(typeFactory, true).init());
+    return tester.withCatalogReaderFactory(MockCatalogReaderExtended::new);
   }
 
   @Test public void testLarge() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java 
b/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
index 58fc09e..d6e3f71 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
@@ -47,8 +47,8 @@ import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlOperatorTable;
 import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.parser.SqlParser;
+import org.apache.calcite.sql.test.SqlTestFactory;
 import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
-import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.sql.validate.SqlConformance;
 import org.apache.calcite.sql.validate.SqlConformanceEnum;
 import org.apache.calcite.sql.validate.SqlMonotonicity;
@@ -60,6 +60,7 @@ import org.apache.calcite.sql2rel.RelFieldTrimmer;
 import org.apache.calcite.sql2rel.SqlToRelConverter;
 import org.apache.calcite.sql2rel.StandardConvertletTable;
 import org.apache.calcite.test.catalog.MockCatalogReader;
+import org.apache.calcite.test.catalog.MockCatalogReaderDynamic;
 import org.apache.calcite.test.catalog.MockCatalogReaderSimple;
 import org.apache.calcite.tools.RelBuilder;
 import org.apache.calcite.util.ImmutableBitSet;
@@ -112,43 +113,7 @@ public abstract class SqlToRelTestBase {
   }
 
   protected Tester getTesterWithDynamicTable() {
-    return tester.withCatalogReaderFactory(
-        typeFactory -> new MockCatalogReader(typeFactory, true) {
-            @Override public MockCatalogReader init() {
-              // CREATE SCHEMA "SALES;
-              // CREATE DYNAMIC TABLE "NATION"
-              // CREATE DYNAMIC TABLE "CUSTOMER"
-
-              MockSchema schema = new MockSchema("SALES");
-              registerSchema(schema);
-
-              MockTable nationTable =
-                  new MockDynamicTable(this, schema.getCatalogName(),
-                      schema.getName(), "NATION", false, 100);
-              registerTable(nationTable);
-
-              MockTable customerTable =
-                  new MockDynamicTable(this, schema.getCatalogName(),
-                      schema.getName(), "CUSTOMER", false, 100);
-              registerTable(customerTable);
-
-              // CREATE TABLE "REGION" - static table with known schema.
-              final RelDataType intType =
-                  typeFactory.createSqlType(SqlTypeName.INTEGER);
-              final RelDataType varcharType =
-                  typeFactory.createSqlType(SqlTypeName.VARCHAR);
-
-              MockTable regionTable =
-                  MockTable.create(this, schema, "REGION", false, 100);
-              regionTable.addColumn("R_REGIONKEY", intType);
-              regionTable.addColumn("R_NAME", varcharType);
-              regionTable.addColumn("R_COMMENT", varcharType);
-              registerTable(regionTable);
-
-              return this;
-            }
-            // CHECKSTYLE: IGNORE 1
-          }.init());
+    return tester.withCatalogReaderFactory(MockCatalogReaderDynamic::new);
   }
 
   /**
@@ -284,7 +249,7 @@ public abstract class SqlToRelTestBase {
     Tester withConformance(SqlConformance conformance);
 
     Tester withCatalogReaderFactory(
-        Function<RelDataTypeFactory, Prepare.CatalogReader> factory);
+        SqlTestFactory.MockCatalogReaderFactory factory);
 
     /** Returns a tester that optionally trims unused fields. */
     Tester withTrim(boolean enable);
@@ -555,7 +520,7 @@ public abstract class SqlToRelTestBase {
     private final boolean enableTrim;
     private final boolean enableExpand;
     private final SqlConformance conformance;
-    private final Function<RelDataTypeFactory, Prepare.CatalogReader> 
catalogReaderFactory;
+    private final SqlTestFactory.MockCatalogReaderFactory catalogReaderFactory;
     private final Function<RelOptCluster, RelOptCluster> clusterFactory;
     private RelDataTypeFactory typeFactory;
     public final SqlToRelConverter.Config config;
@@ -574,7 +539,7 @@ public abstract class SqlToRelTestBase {
     protected TesterImpl(DiffRepository diffRepos, boolean enableDecorrelate,
         boolean enableTrim, boolean enableExpand,
         boolean enableLateDecorrelate,
-        Function<RelDataTypeFactory, Prepare.CatalogReader>
+        SqlTestFactory.MockCatalogReaderFactory
             catalogReaderFactory,
         Function<RelOptCluster, RelOptCluster> clusterFactory) {
       this(diffRepos, enableDecorrelate, enableTrim, enableExpand,
@@ -588,8 +553,7 @@ public abstract class SqlToRelTestBase {
 
     protected TesterImpl(DiffRepository diffRepos, boolean enableDecorrelate,
         boolean enableTrim, boolean enableExpand, boolean 
enableLateDecorrelate,
-        Function<RelDataTypeFactory, Prepare.CatalogReader>
-            catalogReaderFactory,
+        SqlTestFactory.MockCatalogReaderFactory catalogReaderFactory,
         Function<RelOptCluster, RelOptCluster> clusterFactory,
         SqlToRelConverter.Config config, SqlConformance conformance,
         Context context) {
@@ -731,10 +695,13 @@ public abstract class SqlToRelTestBase {
 
     public Prepare.CatalogReader createCatalogReader(
         RelDataTypeFactory typeFactory) {
+      MockCatalogReader catalogReader;
       if (this.catalogReaderFactory != null) {
-        return catalogReaderFactory.apply(typeFactory);
+        catalogReader = catalogReaderFactory.create(typeFactory, true);
+      } else {
+        catalogReader = new MockCatalogReaderSimple(typeFactory, true);
       }
-      return new MockCatalogReaderSimple(typeFactory, true).init();
+      return catalogReader.init();
     }
 
     public RelOptPlanner createPlanner() {
@@ -841,7 +808,7 @@ public abstract class SqlToRelTestBase {
     }
 
     public Tester withCatalogReaderFactory(
-        Function<RelDataTypeFactory, Prepare.CatalogReader> factory) {
+        SqlTestFactory.MockCatalogReaderFactory factory) {
       return new TesterImpl(diffRepos, enableDecorrelate, false,
           enableExpand, enableLateDecorrelate, factory,
           clusterFactory, config, conformance, context);

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/SqlValidatorDynamicTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/test/SqlValidatorDynamicTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorDynamicTest.java
new file mode 100644
index 0000000..1863157
--- /dev/null
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorDynamicTest.java
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.test;
+
+import org.apache.calcite.sql.test.SqlTestFactory;
+import org.apache.calcite.sql.test.SqlTester;
+import org.apache.calcite.sql.test.SqlTesterImpl;
+import org.apache.calcite.test.catalog.MockCatalogReaderDynamic;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Locale;
+
+/**
+ * Concrete child class of {@link SqlValidatorTestCase}, containing lots of 
unit
+ * tests.
+ *
+ * <p>If you want to run these same tests in a different environment, create a
+ * derived class whose {@link #getTester} returns a different implementation of
+ * {@link SqlTester}.
+ */
+public class SqlValidatorDynamicTest extends SqlValidatorTestCase {
+  //~ Static fields/initializers ---------------------------------------------
+
+  /**
+   * @deprecated Deprecated so that usages of this constant will show up in
+   * yellow in Intellij and maybe someone will fix them.
+   */
+  protected static final boolean TODO = false;
+  private static final String ANY = "(?s).*";
+
+  protected static final Logger LOGGER =
+      LoggerFactory.getLogger(SqlValidatorDynamicTest.class);
+
+  private static final String ERR_IN_VALUES_INCOMPATIBLE =
+      "Values in expression list must have compatible types";
+
+  private static final String ERR_IN_OPERANDS_INCOMPATIBLE =
+      "Values passed to IN operator must have compatible types";
+
+  private static final String ERR_AGG_IN_GROUP_BY =
+      "Aggregate expression is illegal in GROUP BY clause";
+
+  private static final String ERR_AGG_IN_ORDER_BY =
+      "Aggregate expression is illegal in ORDER BY clause of non-aggregating 
SELECT";
+
+  private static final String ERR_NESTED_AGG =
+      "Aggregate expressions cannot be nested";
+
+  private static final String EMP_RECORD_TYPE =
+      "RecordType(INTEGER NOT NULL EMPNO,"
+          + " VARCHAR(20) NOT NULL ENAME,"
+          + " VARCHAR(10) NOT NULL JOB,"
+          + " INTEGER MGR,"
+          + " TIMESTAMP(0) NOT NULL HIREDATE,"
+          + " INTEGER NOT NULL SAL,"
+          + " INTEGER NOT NULL COMM,"
+          + " INTEGER NOT NULL DEPTNO,"
+          + " BOOLEAN NOT NULL SLACKER) NOT NULL";
+
+  private static final String STR_AGG_REQUIRES_MONO =
+      "Streaming aggregation requires at least one monotonic expression in 
GROUP BY clause";
+
+  private static final String STR_ORDER_REQUIRES_MONO =
+      "Streaming ORDER BY must start with monotonic expression";
+
+  private static final String STR_SET_OP_INCONSISTENT =
+      "Set operator cannot combine streaming and non-streaming inputs";
+
+  private static final String ROW_RANGE_NOT_ALLOWED_WITH_RANK =
+      "ROW/RANGE not allowed with RANK, DENSE_RANK or ROW_NUMBER functions";
+
+  //~ Constructors -----------------------------------------------------------
+
+  public SqlValidatorDynamicTest() {
+    super();
+  }
+
+  @Override public SqlTester getTester() {
+    // Dymamic schema should not be reused since it is mutable, so
+    // we create new SqlTestFactory for each test
+    return new SqlTesterImpl(SqlTestFactory.INSTANCE
+        .withCatalogReader(MockCatalogReaderDynamic::new));
+  }
+//~ Methods ----------------------------------------------------------------
+
+  @BeforeClass public static void setUSLocale() {
+    // This ensures numbers in exceptions are printed as in asserts.
+    // For example, 1,000 vs 1 000
+    Locale.setDefault(Locale.US);
+  }
+
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-1150";>[CALCITE-1150]
+   * Dynamic Table / Dynamic Star support</a>. */
+  @Test public void testAmbiguousDynamicStar() throws Exception {
+    final String sql = "select ^n_nation^\n"
+        + "from (select * from \"SALES\".NATION),\n"
+        + " (select * from \"SALES\".CUSTOMER)";
+    sql(sql).fails("Column 'N_NATION' is ambiguous");
+  }
+
+  @Test public void testAmbiguousDynamicStar2() throws Exception {
+    final String sql = "select ^n_nation^\n"
+        + "from (select * from \"SALES\".NATION, \"SALES\".CUSTOMER)";
+    sql(sql).fails("Column 'N_NATION' is ambiguous");
+  }
+
+  @Test public void testAmbiguousDynamicStar3() throws Exception {
+    final String sql = "select ^nc.n_nation^\n"
+        + "from (select * from \"SALES\".NATION, \"SALES\".CUSTOMER) as nc";
+    sql(sql).fails("Column 'N_NATION' is ambiguous");
+  }
+
+  @Test public void testAmbiguousDynamicStar4() throws Exception {
+    final String sql = "select n.n_nation\n"
+        + "from (select * from \"SALES\".NATION) as n,\n"
+        + " (select * from \"SALES\".CUSTOMER)";
+    sql(sql).type("RecordType(ANY N_NATION) NOT NULL");
+  }
+
+  /** When resolve column reference, regular field has higher priority than
+   * dynamic star columns. */
+  @Test public void testDynamicStar2() throws Exception {
+    final String sql = "select newid from (\n"
+        + "  select *, NATION.N_NATION + 100 as newid\n"
+        + "  from \"SALES\".NATION, \"SALES\".CUSTOMER)";
+    sql(sql).type("RecordType(ANY NEWID) NOT NULL");
+  }
+
+}
+
+// End SqlValidatorDynamicTest.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java 
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index 45fe7b4..abfdc57 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -9859,44 +9859,6 @@ public class SqlValidatorTest extends 
SqlValidatorTestCase {
         .fails("Column 'F0\\.C1\\.NOTFOUND' not found in table '" + table + 
"'");
   }
 
-  /** Test case for
-   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-1150";>[CALCITE-1150]
-   * Dynamic Table / Dynamic Star support</a>. */
-  @Test public void testAmbiguousDynamicStar() throws Exception {
-    final String sql = "select ^n_nation^\n"
-        + "from (select * from \"DYNAMIC\".NATION),\n"
-        + " (select * from \"DYNAMIC\".CUSTOMER)";
-    sql(sql).fails("Column 'N_NATION' is ambiguous");
-  }
-
-  @Test public void testAmbiguousDynamicStar2() throws Exception {
-    final String sql = "select ^n_nation^\n"
-        + "from (select * from \"DYNAMIC\".NATION, \"DYNAMIC\".CUSTOMER)";
-    sql(sql).fails("Column 'N_NATION' is ambiguous");
-  }
-
-  @Test public void testAmbiguousDynamicStar3() throws Exception {
-    final String sql = "select ^nc.n_nation^\n"
-        + "from (select * from \"DYNAMIC\".NATION, \"DYNAMIC\".CUSTOMER) as 
nc";
-    sql(sql).fails("Column 'N_NATION' is ambiguous");
-  }
-
-  @Test public void testAmbiguousDynamicStar4() throws Exception {
-    final String sql = "select n.n_nation\n"
-        + "from (select * from \"DYNAMIC\".NATION) as n,\n"
-        + " (select * from \"DYNAMIC\".CUSTOMER)";
-    sql(sql).type("RecordType(ANY N_NATION) NOT NULL");
-  }
-
-  /** When resolve column reference, regular field has higher priority than
-   * dynamic star columns. */
-  @Test public void testDynamicStar2() throws Exception {
-    final String sql = "select newid from (\n"
-        + "  select *, NATION.N_NATION + 100 as newid\n"
-        + "  from \"DYNAMIC\".NATION, \"DYNAMIC\".CUSTOMER)";
-    sql(sql).type("RecordType(ANY NEWID) NOT NULL");
-  }
-
   @Test public void testStreamTumble() {
     // TUMBLE
     sql("select stream tumble_end(rowtime, interval '2' hour) as rowtime\n"

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
 
b/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
new file mode 100644
index 0000000..2841df6
--- /dev/null
+++ 
b/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderDynamic.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.test.catalog;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.sql.type.SqlTypeName;
+
+/**
+ * Registers dynamic tables.
+ *
+ * Non thread-safe.
+ */
+public class MockCatalogReaderDynamic extends MockCatalogReader {
+  /**
+   * Creates a MockCatalogReader.
+   *
+   * <p>Caller must then call {@link #init} to populate with data.</p>
+   *
+   * @param typeFactory   Type factory
+   * @param caseSensitive case sensitivity
+   */
+  public MockCatalogReaderDynamic(RelDataTypeFactory typeFactory,
+      boolean caseSensitive) {
+    super(typeFactory, caseSensitive);
+  }
+
+  @Override public MockCatalogReader init() {
+    // Register "DYNAMIC" schema.
+    MockSchema schema = new MockSchema("SALES");
+    registerSchema(schema);
+
+    MockTable nationTable =
+        new MockDynamicTable(this, schema.getCatalogName(),
+            schema.getName(), "NATION", false, 100);
+    registerTable(nationTable);
+
+    MockTable customerTable =
+        new MockDynamicTable(this, schema.getCatalogName(),
+            schema.getName(), "CUSTOMER", false, 100);
+    registerTable(customerTable);
+
+    // CREATE TABLE "REGION" - static table with known schema.
+    final RelDataType intType =
+        typeFactory.createSqlType(SqlTypeName.INTEGER);
+    final RelDataType varcharType =
+        typeFactory.createSqlType(SqlTypeName.VARCHAR);
+
+    MockTable regionTable =
+        MockTable.create(this, schema, "REGION", false, 100);
+    regionTable.addColumn("R_REGIONKEY", intType);
+    regionTable.addColumn("R_NAME", varcharType);
+    regionTable.addColumn("R_COMMENT", varcharType);
+    registerTable(regionTable);
+
+    return this;
+  }
+}
+
+// End MockCatalogReaderDynamic.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/23eb11eb/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderSimple.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderSimple.java
 
b/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderSimple.java
index c9130d0..c1a08be 100644
--- 
a/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderSimple.java
+++ 
b/core/src/test/java/org/apache/calcite/test/catalog/MockCatalogReaderSimple.java
@@ -182,20 +182,6 @@ public class MockCatalogReaderSimple extends 
MockCatalogReader {
     contactAddressTable.addColumn("MAILING_ADDRESS", addressType);
     registerTable(contactAddressTable);
 
-    // Register "DYNAMIC" schema.
-    MockSchema dynamicSchema = new MockSchema("DYNAMIC");
-    registerSchema(dynamicSchema);
-
-    MockTable nationTable =
-        new MockDynamicTable(this, dynamicSchema.getCatalogName(),
-            dynamicSchema.getName(), "NATION", false, 100);
-    registerTable(nationTable);
-
-    MockTable customerTable =
-        new MockDynamicTable(this, dynamicSchema.getCatalogName(),
-            dynamicSchema.getName(), "CUSTOMER", false, 100);
-    registerTable(customerTable);
-
     // Register "CUSTOMER" schema.
     MockSchema customerSchema = new MockSchema("CUSTOMER");
     registerSchema(customerSchema);

Reply via email to