calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [1/3] calcite git commit: Split the mock catalog into "core" and "extended"
Date Tue, 04 Jul 2017 23:14:30 GMT
Repository: calcite
Updated Branches:
  refs/heads/master 319e888f7 -> f47465236


Split the mock catalog into "core" and "extended"

Not only the extended catalog take longer to create, but it creates
views, which require parsing and validation, and therefore a "simple"
validation test is no longer simple, and tends to hit a lot of spurious
break points before the real action starts happening. For most tests,
the core catalog is sufficient.


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

Branch: refs/heads/master
Commit: df826434d7c674caa29a0d1709a52f3e1013baf5
Parents: 319e888
Author: Julian Hyde <jhyde@apache.org>
Authored: Fri Jun 16 14:30:10 2017 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Mon Jul 3 21:28:03 2017 -0700

----------------------------------------------------------------------
 .../calcite/sql/test/DefaultSqlTestFactory.java |  13 +-
 .../sql/test/DelegatingSqlTestFactory.java      |   7 +
 .../apache/calcite/sql/test/SqlAdvisorTest.java |   3 -
 .../apache/calcite/sql/test/SqlTestFactory.java |   4 +
 .../apache/calcite/test/MockCatalogReader.java  |   9 +-
 .../calcite/test/SqlToRelConverterTest.java     |  93 +--
 .../apache/calcite/test/SqlValidatorTest.java   | 656 ++++++++++++-------
 .../calcite/test/SqlValidatorTestCase.java      |  34 +
 .../calcite/test/SqlToRelConverterTest.xml      |  24 +-
 9 files changed, 542 insertions(+), 301 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java b/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
index b9f9d66..075cac7 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/DefaultSqlTestFactory.java
@@ -79,12 +79,11 @@ public class DefaultSqlTestFactory implements SqlTestFactory {
                     throws Exception {
                   final SqlOperatorTable operatorTable =
                       factory.createOperatorTable(factory);
-                  final boolean caseSensitive =
-                      (Boolean) factory.get("caseSensitive");
                   final JavaTypeFactory typeFactory =
                       new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
-                  return new Xyz(operatorTable, typeFactory,
-                      new MockCatalogReader(typeFactory, caseSensitive).init());
+                  final MockCatalogReader catalogReader =
+                      factory.createCatalogReader(factory, typeFactory);
+                  return new Xyz(operatorTable, typeFactory, catalogReader);
                 }
               });
 
@@ -94,6 +93,12 @@ public class DefaultSqlTestFactory implements SqlTestFactory {
   private DefaultSqlTestFactory() {
   }
 
+  public MockCatalogReader createCatalogReader(SqlTestFactory testFactory,
+      JavaTypeFactory typeFactory) {
+    final boolean caseSensitive = (Boolean) testFactory.get("caseSensitive");
+    return new MockCatalogReader(typeFactory, caseSensitive).init();
+  }
+
   public SqlOperatorTable createOperatorTable(SqlTestFactory factory) {
     final SqlOperatorTable opTab0 =
         (SqlOperatorTable) factory.get("operatorTable");

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/core/src/test/java/org/apache/calcite/sql/test/DelegatingSqlTestFactory.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/DelegatingSqlTestFactory.java b/core/src/test/java/org/apache/calcite/sql/test/DelegatingSqlTestFactory.java
index 395c036..cfd628f 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/DelegatingSqlTestFactory.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/DelegatingSqlTestFactory.java
@@ -16,11 +16,13 @@
  */
 package org.apache.calcite.sql.test;
 
+import org.apache.calcite.adapter.java.JavaTypeFactory;
 import org.apache.calcite.sql.SqlOperatorTable;
 import org.apache.calcite.sql.advise.SqlAdvisor;
 import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql.validate.SqlValidator;
 import org.apache.calcite.sql.validate.SqlValidatorWithHints;
+import org.apache.calcite.test.MockCatalogReader;
 
 /**
 * Implementation of {@link SqlTestFactory} that delegates
@@ -46,6 +48,11 @@ public class DelegatingSqlTestFactory implements SqlTestFactory {
     return factory.get(name);
   }
 
+  public MockCatalogReader createCatalogReader(SqlTestFactory factory,
+      JavaTypeFactory typeFactory) {
+    return this.factory.createCatalogReader(factory, typeFactory);
+  }
+
   public SqlOperatorTable createOperatorTable(SqlTestFactory factory) {
     return this.factory.createOperatorTable(factory);
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/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 51ca055..d080773 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
@@ -72,9 +72,6 @@ public class SqlAdvisorTest extends SqlValidatorTestCase {
           "TABLE(CATALOG.SALES.EMPDEFAULTS)",
           "TABLE(CATALOG.SALES.EMPNULLABLES)",
           "TABLE(CATALOG.SALES.EMP_B)",
-          "TABLE(CATALOG.SALES.EMP_MODIFIABLEVIEW)",
-          "TABLE(CATALOG.SALES.EMP_MODIFIABLEVIEW2)",
-          "TABLE(CATALOG.SALES.EMP_MODIFIABLEVIEW3)",
           "TABLE(CATALOG.SALES.EMP_20)",
           "TABLE(CATALOG.SALES.EMPNULLABLES_20)",
           "TABLE(CATALOG.SALES.EMP_ADDRESS)",

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/core/src/test/java/org/apache/calcite/sql/test/SqlTestFactory.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlTestFactory.java b/core/src/test/java/org/apache/calcite/sql/test/SqlTestFactory.java
index fabae76..f4dd25a 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlTestFactory.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlTestFactory.java
@@ -16,11 +16,13 @@
  */
 package org.apache.calcite.sql.test;
 
+import org.apache.calcite.adapter.java.JavaTypeFactory;
 import org.apache.calcite.sql.SqlOperatorTable;
 import org.apache.calcite.sql.advise.SqlAdvisor;
 import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql.validate.SqlValidator;
 import org.apache.calcite.sql.validate.SqlValidatorWithHints;
+import org.apache.calcite.test.MockCatalogReader;
 
 /**
 * Creates the objects needed to run a SQL parsing or validation test.
@@ -28,6 +30,8 @@ import org.apache.calcite.sql.validate.SqlValidatorWithHints;
  * @see org.apache.calcite.sql.test.SqlTester
 */
 public interface SqlTestFactory {
+  MockCatalogReader createCatalogReader(SqlTestFactory testFactory,
+      JavaTypeFactory typeFactory);
   SqlOperatorTable createOperatorTable(SqlTestFactory factory);
   SqlParser createParser(SqlTestFactory factory, String sql);
   SqlValidator getValidator(SqlTestFactory factory);

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java b/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
index c6b5905..59812d7 100644
--- a/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
+++ b/core/src/test/java/org/apache/calcite/test/MockCatalogReader.java
@@ -519,10 +519,15 @@ public class MockCatalogReader extends CalciteCatalogReader {
     }
     registerTable(struct10View);
 
-    return init2(salesSchema);
+    return this;
   }
 
-  private MockCatalogReader init2(MockSchema salesSchema) {
+  /** Adds some extra tables to the mock catalog. These increase the time and
+   * complexity of initializing the catalog (because they contain views whose
+   * SQL needs to be parsed) and so are not used for all tests. */
+  public MockCatalogReader init2() {
+    MockSchema salesSchema = new MockSchema("SALES");
+
     // Same as "EMP_20" except it uses ModifiableViewTable which populates
     // constrained columns with default values on INSERT and has a single constraint on DEPTNO.
     List<String> empModifiableViewNames = ImmutableList.of(

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/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 a596c9b..2717f48 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -827,60 +827,63 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
   }
 
   @Test public void testModifiableViewExtend() {
-    final String sql = "select * from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)";
-    sql(sql).ok();
+    final String sql = "select *\n"
+        + "from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testModifiableViewExtendSubset() {
-    final String sql = "select x, empno from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)";
-    sql(sql).ok();
+    final String sql = "select x, empno\n"
+        + "from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testModifiableViewExtendExpression() {
-    final String sql = "select empno + x from EMP_MODIFIABLEVIEW extend (x int not null)";
-    sql(sql).ok();
+    final String sql = "select empno + x\n"
+        + "from EMP_MODIFIABLEVIEW extend (x int not null)";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectViewExtendedColumnCollision() {
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR\n"
         + " from EMP_MODIFIABLEVIEW3\n"
-        + " where SAL = 20").ok();
+        + " where SAL = 20").with(getExtendedTester()).ok();
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR\n"
         + " from EMP_MODIFIABLEVIEW3 extend (SAL int)\n"
-        + " where SAL = 20").ok();
+        + " where SAL = 20").with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectViewExtendedColumnCaseSensitiveCollision() {
     sql("select ENAME, EMPNO, JOB, SLACKER, \"sal\", HIREDATE, MGR\n"
         + " from EMP_MODIFIABLEVIEW3 extend (\"sal\" boolean)\n"
-        + " where \"sal\" = true").ok();
+        + " where \"sal\" = true").with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectViewExtendedColumnExtendedCollision() {
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, EXTRA\n"
         + " from EMP_MODIFIABLEVIEW2\n"
-        + " where SAL = 20").ok();
+        + " where SAL = 20").with(getExtendedTester()).ok();
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, EXTRA\n"
         + " from EMP_MODIFIABLEVIEW2 extend (EXTRA boolean)\n"
-        + " where SAL = 20").ok();
+        + " where SAL = 20").with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectViewExtendedColumnCaseSensitiveExtendedCollision() {
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, \"extra\"\n"
         + " from EMP_MODIFIABLEVIEW2 extend (\"extra\" boolean)\n"
-        + " where \"extra\" = false").ok();
+        + " where \"extra\" = false").with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectViewExtendedColumnUnderlyingCollision() {
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM\n"
         + " from EMP_MODIFIABLEVIEW3 extend (COMM int)\n"
-        + " where SAL = 20").ok();
+        + " where SAL = 20").with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectViewExtendedColumnCaseSensitiveUnderlyingCollision() {
     sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, \"comm\"\n"
         + " from EMP_MODIFIABLEVIEW3 extend (\"comm\" int)\n"
-        + " where \"comm\" = 20").ok();
+        + " where \"comm\" = 20").with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateExtendedColumnCollision() {
@@ -898,41 +901,42 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
   @Test public void testUpdateExtendedColumnModifiableViewCollision() {
     sql("update EMP_MODIFIABLEVIEW3(empno INTEGER NOT NULL, deptno INTEGER)"
         + " set deptno = 20, empno = 20, ename = 'Bob'"
-        + " where empno = 10").ok();
+        + " where empno = 10").with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewCaseSensitiveCollision() {
     sql("update EMP_MODIFIABLEVIEW2(\"slacker\" INTEGER, deptno INTEGER)"
         + " set deptno = 20, \"slacker\" = 100"
-        + " where ename = 'Bob'").ok();
+        + " where ename = 'Bob'").with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewExtendedCollision() {
     sql("update EMP_MODIFIABLEVIEW2(\"slacker\" INTEGER, extra BOOLEAN)"
         + " set deptno = 20, \"slacker\" = 100, extra = true"
-        + " where ename = 'Bob'").ok();
+        + " where ename = 'Bob'").with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewExtendedCaseSensitiveCollision() {
     sql("update EMP_MODIFIABLEVIEW2(\"extra\" INTEGER, extra BOOLEAN)"
         + " set deptno = 20, \"extra\" = 100, extra = true"
-        + " where ename = 'Bob'").ok();
+        + " where ename = 'Bob'").with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewUnderlyingCollision() {
     sql("update EMP_MODIFIABLEVIEW3(extra BOOLEAN, comm INTEGER)"
         + " set empno = 20, comm = true, extra = true"
-        + " where ename = 'Bob'").ok();
+        + " where ename = 'Bob'").with(getExtendedTester()).ok();
   }
 
   @Test public void testSelectModifiableViewConstraint() {
-    final String sql = "select deptno from EMP_MODIFIABLEVIEW2 where deptno = ?";
-    sql(sql).ok();
+    final String sql = "select deptno from EMP_MODIFIABLEVIEW2\n"
+        + "where deptno = ?";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
-  @Test public void testModifiableViewDDLExtend() {
+  @Test public void testModifiableViewDdlExtend() {
     final String sql = "select extra from EMP_MODIFIABLEVIEW2";
-    sql(sql).ok();
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testExplicitTable() {
@@ -1797,14 +1801,14 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
     final String sql = "insert into EMP_MODIFIABLEVIEW2(updated TIMESTAMP)"
         + " (ename, deptno, empno, updated, sal)"
         + " values ('Fred', 20, 44, timestamp '2017-03-12 13:03:05', 999999)";
-    sql(sql).ok();
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testInsertBindExtendedColumnModifiableView() {
     final String sql = "insert into EMP_MODIFIABLEVIEW2(updated TIMESTAMP)"
         + " (ename, deptno, empno, updated, sal)"
         + " values ('Fred', 20, 44, ?, 999999)";
-    sql(sql).ok();
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testDelete() {
@@ -1829,12 +1833,13 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
 
   @Test public void testDeleteBindModifiableView() {
     final String sql = "delete from EMP_MODIFIABLEVIEW2 where empno = ?";
-    sql(sql).ok();
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testDeleteBindExtendedColumnModifiableView() {
-    final String sql = "delete from EMP_MODIFIABLEVIEW2(note VARCHAR) where note = ?";
-    sql(sql).ok();
+    final String sql = "delete from EMP_MODIFIABLEVIEW2(note VARCHAR)\n"
+        + "where note = ?";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdate() {
@@ -1856,8 +1861,9 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
   }
 
   @Test public void testUpdateModifiableView() {
-    final String sql = "update EMP_MODIFIABLEVIEW2 set sal = sal + 5000 where slacker = false";
-    sql(sql).ok();
+    final String sql = "update EMP_MODIFIABLEVIEW2\n"
+        + "set sal = sal + 5000 where slacker = false";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateExtendedColumn() {
@@ -1868,9 +1874,10 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
   }
 
   @Test public void testUpdateExtendedColumnModifiableView() {
-    final String sql = "update EMP_MODIFIABLEVIEW2(updated TIMESTAMP)"
-        + " set updated = timestamp '2017-03-12 13:03:05', sal = sal + 5000 where slacker = false";
-    sql(sql).ok();
+    final String sql = "update EMP_MODIFIABLEVIEW2(updated TIMESTAMP)\n"
+        + "set updated = timestamp '2017-03-12 13:03:05', sal = sal + 5000\n"
+        + "where slacker = false";
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testUpdateBind() {
@@ -1921,25 +1928,27 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
   @Test public void testInsertModifiableView() {
     final String sql = "insert into EMP_MODIFIABLEVIEW (EMPNO, ENAME, JOB)"
         + " values (34625, 'nom', 'accountant')";
-    sql(sql).ok();
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testInsertSubsetModifiableView() {
     final String sql = "insert into EMP_MODIFIABLEVIEW "
         + "values (10, 'Fred')";
-    sql(sql).conformance(SqlConformanceEnum.PRAGMATIC_2003).ok();
+    sql(sql).with(getExtendedTester())
+        .conformance(SqlConformanceEnum.PRAGMATIC_2003).ok();
   }
 
   @Test public void testInsertBindModifiableView() {
     final String sql = "insert into EMP_MODIFIABLEVIEW (empno, job)"
         + " values (?, ?)";
-    sql(sql).ok();
+    sql(sql).with(getExtendedTester()).ok();
   }
 
   @Test public void testInsertBindSubsetModifiableView() {
     final String sql = "insert into EMP_MODIFIABLEVIEW"
         + " values (?, ?)";
-    sql(sql).conformance(SqlConformanceEnum.PRAGMATIC_2003).ok();
+    sql(sql).conformance(SqlConformanceEnum.PRAGMATIC_2003)
+        .with(getExtendedTester()).ok();
   }
 
   @Test public void testInsertWithCustomColumnResolving() {
@@ -2400,6 +2409,16 @@ public class SqlToRelConverterTest extends SqlToRelTestBase {
     sql(sql).withConfig(convertConfig).convertsTo("${planConverted}");
   }
 
+  private Tester getExtendedTester() {
+    return tester.withCatalogReaderFactory(
+      new Function<RelDataTypeFactory, Prepare.CatalogReader>() {
+        public Prepare.CatalogReader apply(RelDataTypeFactory typeFactory) {
+          return new MockCatalogReader(typeFactory, true)
+              .init().init2();
+        }
+      });
+  }
+
   private Tester getTesterWithDynamicTable() {
     return tester.withCatalogReaderFactory(
         new Function<RelDataTypeFactory, Prepare.CatalogReader>() {

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/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 c8ede98..d262fa6 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -8586,20 +8586,20 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testInsertModifiableView() {
-    tester.checkQuery("insert into EMP_MODIFIABLEVIEW (empno, ename, job)\n"
-        + "values (1, 'Arthur', 'clown')");
-    tester.checkQuery("insert into EMP_MODIFIABLEVIEW2 (empno, ename, job, extra)\n"
-        + "values (1, 'Arthur', 'clown', true)");
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("insert into EMP_MODIFIABLEVIEW (empno, ename, job)\n"
+        + "values (1, 'Arthur', 'clown')").ok();
+    s.sql("insert into EMP_MODIFIABLEVIEW2 (empno, ename, job, extra)\n"
+        + "values (1, 'Arthur', 'clown', true)").ok();
   }
 
   @Test public void testInsertSubsetModifiableView() {
-    final SqlTester pragmaticTester =
-        tester.withConformance(SqlConformanceEnum.PRAGMATIC_2003);
-    pragmaticTester.checkQuery("insert into EMP_MODIFIABLEVIEW2\n"
-        + "values ('Arthur', 1)");
-    tester.checkQuery("insert into EMP_MODIFIABLEVIEW2\n"
+    final Sql s = sql("?").withExtendedCatalog2003();
+    s.sql("insert into EMP_MODIFIABLEVIEW2\n"
+        + "values ('Arthur', 1)").ok();
+    s.sql("insert into EMP_MODIFIABLEVIEW2\n"
         + "values ('Arthur', 1, 'Knight', 20, false, 99999, true, timestamp '1370-01-01 00:00:00',"
-        + " 1, 100)");
+        + " 1, 100)").ok();
   }
 
   @Test public void testInsertBind() {
@@ -8710,58 +8710,66 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   @Test public void testInsertBindView() {
     final String sql = "insert into EMP_MODIFIABLEVIEW (mgr, empno, ename)"
         + " values (?, ?, ?)";
-    sql(sql).ok().bindType("RecordType(INTEGER ?0, INTEGER ?1, VARCHAR(20) ?2)");
+    sql(sql).withExtendedCatalog().ok()
+        .bindType("RecordType(INTEGER ?0, INTEGER ?1, VARCHAR(20) ?2)");
   }
 
   @Test public void testInsertModifiableViewPassConstraint() {
-    sql("insert into EMP_MODIFIABLEVIEW2 (deptno, empno, ename, extra)"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("insert into EMP_MODIFIABLEVIEW2 (deptno, empno, ename, extra)"
         + " values (20, 100, 'Lex', true)").ok();
-    sql("insert into EMP_MODIFIABLEVIEW2 (empno, ename, extra)"
+    s.sql("insert into EMP_MODIFIABLEVIEW2 (empno, ename, extra)"
         + " values (100, 'Lex', true)").ok();
-    sql("insert into EMP_MODIFIABLEVIEW2 values ('Edward', 20)")
-        .tester(tester.withConformance(SqlConformanceEnum.PRAGMATIC_2003)).ok();
+
+    final Sql s2 = sql("?").withExtendedCatalog2003();
+    s2.sql("insert into EMP_MODIFIABLEVIEW2 values ('Edward', 20)").ok();
   }
 
   @Test public void testInsertModifiableViewFailConstraint() {
-    tester.checkQueryFails(
-        "insert into EMP_MODIFIABLEVIEW2 (deptno, empno, ename)"
-            + " values (^21^, 100, 'Lex')",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
-    tester.checkQueryFails(
-        "insert into EMP_MODIFIABLEVIEW2 (deptno, empno, ename)"
-            + " values (^19+1^, 100, 'Lex')",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2\n"
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW2 (deptno, empno, ename)"
+        + " values (^21^, 100, 'Lex')";
+    final String error0 = "Modifiable view constraint is not satisfied"
+        + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'";
+    s.sql(sql0).fails(error0);
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW2 (deptno, empno, ename)"
+        + " values (^19+1^, 100, 'Lex')";
+    final String error1 = "Modifiable view constraint is not satisfied"
+        + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'";
+    s.sql(sql1).fails(error1);
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW2\n"
         + "values ('Arthur', 1, 'Knight', ^27^, false, 99999, true,"
-            + "timestamp '1370-01-01 00:00:00', 1, 100)",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
+        + "timestamp '1370-01-01 00:00:00', 1, 100)";
+    final String error2 = "Modifiable view constraint is not satisfied"
+        + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'";
+    s.sql(sql2).fails(error2);
   }
 
   @Test public void testUpdateModifiableViewPassConstraint() {
-    sql("update EMP_MODIFIABLEVIEW2"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("update EMP_MODIFIABLEVIEW2"
         + " set deptno = 20, empno = 99"
         + " where ename = 'Lex'").ok();
-    sql("update EMP_MODIFIABLEVIEW2"
+    s.sql("update EMP_MODIFIABLEVIEW2"
         + " set empno = 99"
         + " where ename = 'Lex'").ok();
   }
 
   @Test public void testUpdateModifiableViewFailConstraint() {
-    tester.checkQueryFails(
-        "update EMP_MODIFIABLEVIEW2"
-            + " set deptno = ^21^, empno = 99"
-            + " where ename = 'Lex'",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
-    tester.checkQueryFails(
-        "update EMP_MODIFIABLEVIEW2"
-            + " set deptno = ^19 + 1^, empno = 99"
-            + " where ename = 'Lex'",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "update EMP_MODIFIABLEVIEW2"
+        + " set deptno = ^21^, empno = 99"
+        + " where ename = 'Lex'";
+    final String error = "Modifiable view constraint is not satisfied"
+        + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "update EMP_MODIFIABLEVIEW2"
+        + " set deptno = ^19 + 1^, empno = 99"
+        + " where ename = 'Lex'";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testInsertFailNullability() {
@@ -8860,45 +8868,53 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   @Test public void testSelectExtendedColumnDuplicate() {
     sql("select deptno, extra from emp (extra int, \"extra\" boolean)").ok();
     sql("select deptno, extra from emp (extra int, \"extra\" int)").ok();
-    tester.checkQueryFails("select deptno, extra from emp (extra int, ^extra^ int)",
-        "Duplicate name 'EXTRA' in column list");
-    tester.checkQueryFails("select deptno, extra from emp (extra int, ^extra^ boolean)",
-        "Duplicate name 'EXTRA' in column list");
-    tester.checkQueryFails("select deptno, extra from EMP_MODIFIABLEVIEW (extra int, ^extra^ int)",
-        "Duplicate name 'EXTRA' in column list");
-    tester.checkQueryFails("select deptno, extra from EMP_MODIFIABLEVIEW"
-            + " (extra int, ^extra^ boolean)",
-        "Duplicate name 'EXTRA' in column list");
+    sql("select deptno, extra from emp (extra int, ^extra^ int)")
+        .fails("Duplicate name 'EXTRA' in column list");
+    sql("select deptno, extra from emp (extra int, ^extra^ boolean)")
+        .fails("Duplicate name 'EXTRA' in column list");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "select deptno, extra\n"
+        + "from EMP_MODIFIABLEVIEW (extra int, ^extra^ int)";
+    s.sql(sql0).fails("Duplicate name 'EXTRA' in column list");
+
+    final String sql1 = "select deptno, extra from EMP_MODIFIABLEVIEW"
+        + " (extra int, ^extra^ boolean)";
+    s.sql(sql1).fails("Duplicate name 'EXTRA' in column list");
   }
 
   @Test public void testSelectViewFailExcludedColumn() {
-    tester.checkQueryFails("select ^deptno^, empno from EMP_MODIFIABLEVIEW",
-        "Column 'DEPTNO' not found in any table");
+    final String sql = "select ^deptno^, empno from EMP_MODIFIABLEVIEW";
+    final String error = "Column 'DEPTNO' not found in any table";
+    sql(sql).withExtendedCatalog().fails(error);
   }
 
   @Test public void testSelectViewExtendedColumnCollision() {
-    sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR\n"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR\n"
         + " from EMP_MODIFIABLEVIEW3 extend (SAL int)\n"
         + " where SAL = 20").ok();
-    sql("select ENAME, EMPNO, JOB, SLACKER, SAL, \"Sal\", HIREDATE, MGR\n"
+    s.sql("select ENAME, EMPNO, JOB, SLACKER, SAL, \"Sal\", HIREDATE, MGR\n"
         + " from EMP_MODIFIABLEVIEW3 extend (\"Sal\" VARCHAR)\n"
         + " where SAL = 20").ok();
   }
 
   @Test public void testSelectViewExtendedColumnExtendedCollision() {
-    sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA\n"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA\n"
         + " from EMP_MODIFIABLEVIEW2 extend (EXTRA boolean)\n"
         + " where SAL = 20").ok();
-    sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA, \"EXtra\"\n"
+    s.sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA,"
+        + " \"EXtra\"\n"
         + " from EMP_MODIFIABLEVIEW2 extend (\"EXtra\" VARCHAR)\n"
         + " where SAL = 20").ok();
   }
 
   @Test public void testSelectViewExtendedColumnUnderlyingCollision() {
-    sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM\n"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM\n"
         + " from EMP_MODIFIABLEVIEW3 extend (COMM int)\n"
         + " where SAL = 20").ok();
-    sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, \"comM\"\n"
+    s.sql("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, \"comM\"\n"
         + " from EMP_MODIFIABLEVIEW3 extend (\"comM\" BOOLEAN)\n"
         + " where SAL = 20").ok();
   }
@@ -8928,36 +8944,56 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testSelectViewExtendedColumnFailCollision() {
-    tester.checkQueryFails("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA\n"
-            + " from EMP_MODIFIABLEVIEW2 extend (^SLACKER^ integer)\n"
-            + " where SAL = 20",
-        "Cannot assign to target field 'SLACKER' of type BOOLEAN from source field 'SLACKER' of type INTEGER");
-    tester.checkQueryFails("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM\n"
-            + " from EMP_MODIFIABLEVIEW2 extend (^EMPNO^ integer)\n"
-            + " where SAL = 20",
-        "Cannot assign to target field 'EMPNO' of type INTEGER NOT NULL from source field 'EMPNO' of type INTEGER");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE,"
+        + " MGR, EXTRA\n"
+        + "from EMP_MODIFIABLEVIEW2 extend (^SLACKER^ integer)\n"
+        + " where SAL = 20";
+    final String error0 = "Cannot assign to target field 'SLACKER' of type"
+        + " BOOLEAN from source field 'SLACKER' of type INTEGER";
+    s.sql(sql0).fails(error0);
+
+    final String sql1 = "select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE,"
+        + " MGR, COMM\n"
+        + "from EMP_MODIFIABLEVIEW2 extend (^EMPNO^ integer)\n"
+        + " where SAL = 20";
+    final String error1 = "Cannot assign to target field 'EMPNO' of type"
+        + " INTEGER NOT NULL from source field 'EMPNO' of type INTEGER";
+    s.sql(sql1).fails(error1);
   }
 
   @Test public void testSelectViewExtendedColumnFailExtendedCollision() {
-    tester.checkQueryFails("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA\n"
-            + " from EMP_MODIFIABLEVIEW2 extend (^EXTRA^ integer)\n"
-            + " where SAL = 20",
-        "Cannot assign to target field 'EXTRA' of type BOOLEAN from source field 'EXTRA' of type INTEGER");
-    tester.checkQueryFails("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, EXTRA\n"
-            + " from EMP_MODIFIABLEVIEW2 extend (^\"EXTRA\"^ integer)\n"
-            + " where SAL = 20",
-        "Cannot assign to target field 'EXTRA' of type BOOLEAN from source field 'EXTRA' of type INTEGER");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE,"
+        + " MGR, EXTRA\n"
+        + "from EMP_MODIFIABLEVIEW2 extend (^EXTRA^ integer)\n"
+        + " where SAL = 20";
+    final String error = "Cannot assign to target field 'EXTRA' of type"
+        + " BOOLEAN from source field 'EXTRA' of type INTEGER";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE,"
+        + " MGR, EXTRA\n"
+        + "from EMP_MODIFIABLEVIEW2 extend (^\"EXTRA\"^ integer)\n"
+        + " where SAL = 20";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testSelectViewExtendedColumnFailUnderlyingCollision() {
-    tester.checkQueryFails("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM\n"
-            + " from EMP_MODIFIABLEVIEW3 extend (^COMM^ boolean)\n"
-            + " where SAL = 20",
-        "Cannot assign to target field 'COMM' of type INTEGER from source field 'COMM' of type BOOLEAN");
-    tester.checkQueryFails("select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM\n"
-            + " from EMP_MODIFIABLEVIEW3 extend (^\"COMM\"^ boolean)\n"
-            + " where SAL = 20",
-        "Cannot assign to target field 'COMM' of type INTEGER from source field 'COMM' of type BOOLEAN");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE,"
+        + " MGR, COMM\n"
+        + "from EMP_MODIFIABLEVIEW3 extend (^COMM^ boolean)\n"
+        + "where SAL = 20";
+    final String error = "Cannot assign to target field 'COMM' of type INTEGER"
+        + " from source field 'COMM' of type BOOLEAN";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE,"
+        + " MGR, COMM\n"
+        + "from EMP_MODIFIABLEVIEW3 extend (^\"COMM\"^ boolean)\n"
+        + " where SAL = 20";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testSelectFailCaseSensitivity() {
@@ -8970,28 +9006,36 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testInsertFailCaseSensitivity() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW (^\"empno\"^, ename, deptno)"
-            + " values (45, 'Jake', 5)",
-        "Unknown target column 'empno'");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW (\"extra\" int) (^extra^, ename, deptno)"
-            + " values (45, 'Jake', 5)",
-        "Unknown target column 'EXTRA'");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW (extra int) (^\"extra\"^, ename, deptno)"
-            + " values (45, 'Jake', 5)",
-        "Unknown target column 'extra'");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW"
+        + " (^\"empno\"^, ename, deptno)"
+        + " values (45, 'Jake', 5)";
+    s.sql(sql0).fails("Unknown target column 'empno'");
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW (\"extra\" int)"
+        + " (^extra^, ename, deptno)"
+        + " values (45, 'Jake', 5)";
+    s.sql(sql1).fails("Unknown target column 'EXTRA'");
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW (extra int)"
+        + " (^\"extra\"^, ename, deptno)"
+        + " values (45, 'Jake', 5)";
+    s.sql(sql2).fails("Unknown target column 'extra'");
   }
 
   @Test public void testInsertFailExcludedColumn() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW (empno, ename, ^deptno^)"
-        + " values (45, 'Jake', 5)",
-        "Unknown target column 'DEPTNO'");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql = ""
+        + "insert into EMP_MODIFIABLEVIEW (empno, ename, ^deptno^)"
+        + " values (45, 'Jake', 5)";
+    s.sql(sql).fails("Unknown target column 'DEPTNO'");
   }
 
   @Test public void testInsertBindViewFailExcludedColumn() {
+    final Sql s = sql("?").withExtendedCatalog();
     final String sql = "insert into EMP_MODIFIABLEVIEW (empno, ename, ^deptno^)"
         + " values (?, ?, ?)";
-    tester.checkQueryFails(sql,
-        "Unknown target column 'DEPTNO'");
+    s.sql(sql).fails("Unknown target column 'DEPTNO'");
   }
 
   @Test public void testInsertWithCustomInitializerExpressionFactory() {
@@ -9610,66 +9654,88 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testInsertExtendedColumnModifiableView() {
-    sql("insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
-        + " (deptno, empno, ename, extra2, note) values (20, 10, '2', true, 'ok')").ok();
-    sql("insert into EMP_MODIFIABLEVIEW2(\"rank\" INT, extra2 BOOLEAN)"
-        + " values ('nom', 1, 'job', 20, true, 0, false, timestamp '1970-01-01 00:00:00', 1, 1,"
-        + "  1, false)").ok();
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN,"
+        + " note VARCHAR) (deptno, empno, ename, extra2, note)\n"
+        + "values (20, 10, '2', true, 'ok')";
+    s.sql(sql0).ok();
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW2(\"rank\" INT,"
+        + " extra2 BOOLEAN)\n"
+        + "values ('nom', 1, 'job', 20, true, 0, false,"
+        + " timestamp '1970-01-01 00:00:00', 1, 1,  1, false)";
+    s.sql(sql1).ok();
   }
 
   @Test public void testInsertBindExtendedColumnModifiableView() {
-    sql("insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
         + " (deptno, empno, ename, extra2, note) values (20, 10, '2', true, ?)").ok();
-    sql("insert into EMP_MODIFIABLEVIEW2(\"rank\" INT, extra2 BOOLEAN)"
+    s.sql("insert into EMP_MODIFIABLEVIEW2(\"rank\" INT, extra2 BOOLEAN)"
         + " values ('nom', 1, 'job', 20, true, 0, false, timestamp '1970-01-01 00:00:00', 1, 1,"
         + "  ?, false)").ok();
   }
 
   @Test public void testInsertExtendedColumnModifiableViewFailConstraint() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
-        + " (deptno, empno, ename, extra2, note) values (^1^, 10, '2', true, 'ok')",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
-            + " (deptno, empno, ename, extra2, note) values (^?^, 10, '2', true, 'ok')",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(\"rank\" INT, extra2 BOOLEAN)"
-        + " values ('nom', 1, 'job', ^0^, true, 0, false, timestamp '1970-01-01 00:00:00', 1, 1,"
-            + "  1, false)",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN,"
+        + " note VARCHAR) (deptno, empno, ename, extra2, note)\n"
+        + "values (^1^, 10, '2', true, 'ok')";
+    final String error = "Modifiable view constraint is not satisfied"
+        + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW2(extra2 BOOLEAN,"
+        + " note VARCHAR) (deptno, empno, ename, extra2, note)\n"
+        + "values (^?^, 10, '2', true, 'ok')";
+    s.sql(sql1).fails(error);
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW2(\"rank\" INT,"
+        + " extra2 BOOLEAN)\n"
+        + "values ('nom', 1, 'job', ^0^, true, 0, false,"
+        + " timestamp '1970-01-01 00:00:00', 1, 1,  1, false)";
+    s.sql(sql2).fails(error);
   }
 
   @Test public void testInsertExtendedColumnModifiableViewFailColumnCount() {
+    final Sql s = sql("?").withExtendedCatalog();
     final String sql0 = "insert into ^EMP_MODIFIABLEVIEW2(\"rank\" INT, extra2 BOOLEAN)^"
         + " values ('nom', 1, 'job', 0, true, 0, false,"
         + " timestamp '1970-01-01 00:00:00', 1, 1,  1)";
-    tester.checkQueryFails(sql0,
-        "Number of INSERT target columns \\(12\\) does not equal number of source items \\(11\\)");
+    final String error0 = "Number of INSERT target columns \\(12\\) does not"
+        + " equal number of source items \\(11\\)";
+    s.sql(sql0).fails(error0);
+
     final String sql1 = "insert into ^EMP_MODIFIABLEVIEW2(\"rank\" INT, extra2 BOOLEAN)^"
         + " (deptno, empno, ename, extra2, \"rank\") values (?, 10, '2', true)";
-    tester.checkQueryFails(sql1,
-        "Number of INSERT target columns \\(5\\) does not equal number of source items \\(4\\)");
+    final String error1 = "Number of INSERT target columns \\(5\\) does not"
+        + " equal number of source items \\(4\\)";
+    s.sql(sql1).fails(error1);
   }
 
   @Test public void testInsertExtendedColumnFailDuplicate() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(extcol INT, ^extcol^ BOOLEAN)"
-            + " values ('nom', 1, 'job', 0, true, 0, false, timestamp '1970-01-01 00:00:00', 1, 1,"
-            + "  1)",
-        "Duplicate name 'EXTCOL' in column list");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(extcol INT, ^extcol^ BOOLEAN)"
-            + " (extcol) values (1)",
-        "Duplicate name 'EXTCOL' in column list");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(extcol INT, ^extcol^ BOOLEAN)"
-            + " (extcol) values (false)",
-        "Duplicate name 'EXTCOL' in column list");
-    tester.checkQueryFails("insert into EMP(extcol INT, ^extcol^ BOOLEAN)"
-            + " (extcol) values (1)",
-        "Duplicate name 'EXTCOL' in column list");
-    tester.checkQueryFails("insert into EMP(extcol INT, ^extcol^ BOOLEAN)"
-            + " (extcol) values (false)",
-        "Duplicate name 'EXTCOL' in column list");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW2(extcol INT,"
+        + " ^extcol^ BOOLEAN)\n"
+        + "values ('nom', 1, 'job', 0, true, 0, false,"
+        + " timestamp '1970-01-01 00:00:00', 1, 1,  1)";
+    final String error = "Duplicate name 'EXTCOL' in column list";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW2(extcol INT,"
+        + " ^extcol^ BOOLEAN) (extcol) values (1)";
+    s.sql(sql1).fails(error);
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW2(extcol INT,"
+        + " ^extcol^ BOOLEAN) (extcol) values (false)";
+    s.sql(sql2).fails(error);
+
+    final String sql3 = "insert into EMP(extcol INT, ^extcol^ BOOLEAN)"
+        + " (extcol) values (1)";
+    s.sql(sql3).fails(error);
+
+    final String sql4 = "insert into EMP(extcol INT, ^extcol^ BOOLEAN)"
+        + " (extcol) values (false)";
+    s.sql(sql4).fails(error);
   }
 
   @Test public void testUpdateExtendedColumn() {
@@ -9743,34 +9809,40 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testUpdateExtendedColumnModifiableView() {
-    sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
         + " set deptno = 20, extra2 = true, empno = 20, ename = 'Bob', note = 'legion'"
         + " where ename = 'Jane'").ok();
-    sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN)"
+    s.sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN)"
         + " set extra2 = true, ename = 'Bob'"
         + " where ename = 'Jane'").ok();
   }
 
   @Test public void testUpdateBindExtendedColumnModifiableView() {
-    sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
         + " set deptno = 20, extra2 = true, empno = 20, ename = 'Bob', note = ?"
         + " where ename = 'Jane'").ok();
-    sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN)"
+    s.sql("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN)"
         + " set extra2 = ?, ename = 'Bob'"
         + " where ename = 'Jane'").ok();
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewFailConstraint() {
-    tester.checkQueryFails("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN, note VARCHAR)"
-            + " set deptno = ^1^, extra2 = true, empno = 20, ename = 'Bob', note = 'legion'"
-            + " where ename = 'Jane'",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
-    tester.checkQueryFails("update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN)"
-            + " set extra2 = true, deptno = ^1^, ename = 'Bob'"
-            + " where ename = 'Jane'",
-        "Modifiable view constraint is not satisfied"
-            + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN,"
+        + " note VARCHAR)\n"
+        + "set deptno = ^1^, extra2 = true, empno = 20, ename = 'Bob',"
+        + " note = 'legion'\n"
+        + "where ename = 'Jane'";
+    final String error = "Modifiable view constraint is not satisfied"
+        + " for column 'DEPTNO' of base table 'EMP_MODIFIABLEVIEW2'";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "update EMP_MODIFIABLEVIEW2(extra2 BOOLEAN)"
+        + " set extra2 = true, deptno = ^1^, ename = 'Bob'"
+        + " where ename = 'Jane'";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testUpdateExtendedColumnCollision() {
@@ -9780,12 +9852,15 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewCollision() {
-    sql("update EMP_MODIFIABLEVIEW3(empno INTEGER NOT NULL, deptno INTEGER)"
-        + " set deptno = 20, empno = 20, ename = 'Bob'"
-        + " where empno = 10").ok();
-    sql("update EMP_MODIFIABLEVIEW3(empno INTEGER NOT NULL, \"deptno\" BOOLEAN)"
-        + " set \"deptno\" = true, empno = 20, ename = 'Bob'"
-        + " where empno = 10").ok();
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("update EMP_MODIFIABLEVIEW3(empno INTEGER NOT NULL,"
+        + " deptno INTEGER)\n"
+        + "set deptno = 20, empno = 20, ename = 'Bob'\n"
+        + "where empno = 10").ok();
+    s.sql("update EMP_MODIFIABLEVIEW3(empno INTEGER NOT NULL,"
+        + " \"deptno\" BOOLEAN)\n"
+        + "set \"deptno\" = true, empno = 20, ename = 'Bob'\n"
+        + "where empno = 10").ok();
   }
 
   @Test public void testUpdateExtendedColumnFailCollision() {
@@ -9804,35 +9879,50 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewFailCollision() {
-    tester.checkQueryFails("update EMP_MODIFIABLEVIEW3(^empno^ BOOLEAN, deptno INTEGER)"
-            + " set deptno = 1, empno = false, ename = 'Bob'"
-            + " where deptno = 10",
-        "Cannot assign to target field 'EMPNO' of type INTEGER NOT NULL from source field 'EMPNO' of type BOOLEAN");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql = "update EMP_MODIFIABLEVIEW3(^empno^ BOOLEAN,"
+        + " deptno INTEGER)\n"
+        + "set deptno = 1, empno = false, ename = 'Bob'\n"
+        + "where deptno = 10";
+    final String error = "Cannot assign to target field 'EMPNO' of type"
+        + " INTEGER NOT NULL from source field 'EMPNO' of type BOOLEAN";
+    s.sql(sql).fails(error);
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewFailExtendedCollision() {
-    tester.checkQueryFails("update EMP_MODIFIABLEVIEW2(^extra^ INTEGER, deptno INTEGER)"
-            + " set deptno = 20, empno = 20, ename = 'Bob', extra = 5"
-            + " where empno = 10",
-        "Cannot assign to target field 'EXTRA' of type BOOLEAN from source field 'EXTRA' of type INTEGER");
+    final String error = "Cannot assign to target field 'EXTRA' of type"
+        + " BOOLEAN from source field 'EXTRA' of type INTEGER";
+    final String sql = "update EMP_MODIFIABLEVIEW2(^extra^ INTEGER,"
+        + " deptno INTEGER)\n"
+        + "set deptno = 20, empno = 20, ename = 'Bob', extra = 5\n"
+        + "where empno = 10";
+    sql(sql).withExtendedCatalog().fails(error);
   }
 
   @Test public void testUpdateExtendedColumnModifiableViewFailUnderlyingCollision() {
-    tester.checkQueryFails("update EMP_MODIFIABLEVIEW3(^comm^ BOOLEAN, deptno INTEGER)"
-            + " set deptno = 1, empno = 20, ename = 'Bob', comm = true"
-            + " where deptno = 10",
-        "Cannot assign to target field 'COMM' of type INTEGER from source field 'COMM' of type BOOLEAN");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql = "update EMP_MODIFIABLEVIEW3(^comm^ BOOLEAN,"
+        + " deptno INTEGER)\n"
+        + "set deptno = 1, empno = 20, ename = 'Bob', comm = true\n"
+        + "where deptno = 10";
+    final String error = "Cannot assign to target field 'COMM' of type"
+        + " INTEGER from source field 'COMM' of type BOOLEAN";
+    s.sql(sql).fails(error);
   }
 
   @Test public void testUpdateExtendedColumnFailDuplicate() {
-    tester.checkQueryFails("update emp(comm BOOLEAN, ^comm^ INTEGER)"
-            + " set deptno = 1, empno = 20, ename = 'Bob', comm = 1"
-            + " where deptno = 10",
-        "Duplicate name 'COMM' in column list");
-    tester.checkQueryFails("update EMP_MODIFIABLEVIEW3(comm BOOLEAN, ^comm^ INTEGER)"
-        + " set deptno = 1, empno = 20, ename = 'Bob', comm = true"
-        + " where deptno = 10",
-        "Duplicate name 'COMM' in column list");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "update emp(comm BOOLEAN, ^comm^ INTEGER)\n"
+        + "set deptno = 1, empno = 20, ename = 'Bob', comm = 1\n"
+        + "where deptno = 10";
+    final String error = "Duplicate name 'COMM' in column list";
+    s.sql(sql0).fails(error);
+
+    final String sql1 = "update EMP_MODIFIABLEVIEW3(comm BOOLEAN,"
+        + " ^comm^ INTEGER)\n"
+        + "set deptno = 1, empno = 20, ename = 'Bob', comm = true\n"
+        + "where deptno = 10";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testInsertExtendedColumnCollision() {
@@ -9841,18 +9931,24 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testInsertExtendedColumnModifiableViewCollision() {
-    sql("insert into EMP_MODIFIABLEVIEW3(^sal^ INTEGER) (empno, ename, job, sal)\n"
-        + "values (1, 'Arthur', 'clown', 5)").ok();
+    final String sql = "insert into EMP_MODIFIABLEVIEW3(^sal^ INTEGER)\n"
+        + " (empno, ename, job, sal)\n"
+        + "values (1, 'Arthur', 'clown', 5)";
+    sql(sql).withExtendedCatalog().ok();
   }
 
   @Test public void testInsertExtendedColumnModifiableViewExtendedCollision() {
-    sql("insert into EMP_MODIFIABLEVIEW2(^extra^ BOOLEAN) (empno, ename, job, extra)\n"
-        + "values (1, 'Arthur', 'clown', true)").ok();
+    final String sql = "insert into EMP_MODIFIABLEVIEW2(^extra^ BOOLEAN)"
+        + " (empno, ename, job, extra)\n"
+        + "values (1, 'Arthur', 'clown', true)";
+    sql(sql).withExtendedCatalog().ok();
   }
 
   @Test public void testInsertExtendedColumnModifiableViewUnderlyingCollision() {
-    sql("insert into EMP_MODIFIABLEVIEW3(^comm^ INTEGER) (empno, ename, job, comm)\n"
-        + "values (1, 'Arthur', 'clown', 5)").ok();
+    final String sql = "insert into EMP_MODIFIABLEVIEW3(^comm^ INTEGER)\n"
+        + " (empno, ename, job, comm)\n"
+        + "values (1, 'Arthur', 'clown', 5)";
+    sql(sql).withExtendedCatalog().ok();
   }
 
   @Test public void testInsertExtendedColumnFailCollision() {
@@ -9874,39 +9970,68 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testInsertExtendedColumnModifiableViewFailCollision() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(^slacker^ INTEGER)"
-            + " (empno, ename, job, slacker) values (1, 'Arthur', 'clown', true)",
-        "Cannot assign to target field 'SLACKER' of type BOOLEAN from source field 'SLACKER' of type INTEGER");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(\"slacker\" INTEGER)"
-            + " (empno, ename, job, ^slacker^) values (1, 'Arthur', 'clown', 1)",
-        "Cannot assign to target field 'SLACKER' of type BOOLEAN from source field 'EXPR\\$3' of type INTEGER");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(\"slacker\" INTEGER)"
-            + " (empno, ename, job, ^\"slacker\"^) values (1, 'Arthur', 'clown', true)",
-        "Cannot assign to target field 'slacker' of type INTEGER from source field 'EXPR\\$3' of type BOOLEAN");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW2(^slacker^ INTEGER)"
+        + " (empno, ename, job, slacker) values (1, 'Arthur', 'clown', true)";
+    final String error0 = "Cannot assign to target field 'SLACKER' of type"
+        + " BOOLEAN from source field 'SLACKER' of type INTEGER";
+    s.sql(sql0).fails(error0);
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW2(\"slacker\" INTEGER)"
+        + " (empno, ename, job, ^slacker^) values (1, 'Arthur', 'clown', 1)";
+    final String error1 = "Cannot assign to target field 'SLACKER' of type"
+        + " BOOLEAN from source field 'EXPR\\$3' of type INTEGER";
+    s.sql(sql1).fails(error1);
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW2(\"slacker\" INTEGER)"
+        + " (empno, ename, job, ^\"slacker\"^)\n"
+        + "values (1, 'Arthur', 'clown', true)";
+    final String error2 = "Cannot assign to target field 'slacker' of type"
+        + " INTEGER from source field 'EXPR\\$3' of type BOOLEAN";
+    s.sql(sql2).fails(error2);
   }
 
   @Test public void testInsertExtendedColumnModifiableViewFailExtendedCollision() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(^extra^ INTEGER)"
-            + " (empno, ename, job, extra) values (1, 'Arthur', 'clown', true)",
-        "Cannot assign to target field 'EXTRA' of type BOOLEAN from source field 'EXTRA' of type INTEGER");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(\"extra\" INTEGER)"
-            + " (empno, ename, job, ^extra^) values (1, 'Arthur', 'clown', 1)",
-        "Cannot assign to target field 'EXTRA' of type BOOLEAN from source field 'EXPR\\$3' of type INTEGER");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW2(\"extra\" INTEGER)"
-            + " (empno, ename, job, ^\"extra\"^) values (1, 'Arthur', 'clown', true)",
-        "Cannot assign to target field 'extra' of type INTEGER from source field 'EXPR\\$3' of type BOOLEAN");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW2(^extra^ INTEGER)"
+        + " (empno, ename, job, extra) values (1, 'Arthur', 'clown', true)";
+    final String error0 = "Cannot assign to target field 'EXTRA' of type"
+        + " BOOLEAN from source field 'EXTRA' of type INTEGER";
+    s.sql(sql0).fails(error0);
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW2(\"extra\" INTEGER)"
+        + " (empno, ename, job, ^extra^) values (1, 'Arthur', 'clown', 1)";
+    final String error1 = "Cannot assign to target field 'EXTRA' of type"
+        + " BOOLEAN from source field 'EXPR\\$3' of type INTEGER";
+    s.sql(sql1).fails(error1);
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW2(\"extra\" INTEGER)"
+        + " (empno, ename, job, ^\"extra\"^)\n"
+        + "values (1, 'Arthur', 'clown', true)";
+    final String error2 = "Cannot assign to target field 'extra' of type"
+        + " INTEGER from source field 'EXPR\\$3' of type BOOLEAN";
+    s.sql(sql2).fails(error2);
   }
 
   @Test public void testInsertExtendedColumnModifiableViewFailUnderlyingCollision() {
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW3(^comm^ BOOLEAN)"
-            + " (empno, ename, job, comm) values (1, 'Arthur', 'clown', true)",
-        "Cannot assign to target field 'COMM' of type INTEGER from source field 'COMM' of type BOOLEAN");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW3(\"comm\" BOOLEAN)"
-            + " (empno, ename, job, ^comm^) values (1, 'Arthur', 'clown', 5)",
-        "Unknown target column 'COMM'");
-    tester.checkQueryFails("insert into EMP_MODIFIABLEVIEW3(\"comm\" BOOLEAN)"
-            + " (empno, ename, job, ^\"comm\"^) values (1, 'Arthur', 'clown', 1)",
-        "Cannot assign to target field 'comm' of type BOOLEAN from source field 'EXPR\\$3' of type INTEGER");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String error0 = "Cannot assign to target field 'COMM' of type"
+        + " INTEGER from source field 'COMM' of type BOOLEAN";
+    final String sql0 = "insert into EMP_MODIFIABLEVIEW3(^comm^ BOOLEAN)"
+        + " (empno, ename, job, comm) values (1, 'Arthur', 'clown', true)";
+    s.sql(sql0).fails(error0);
+
+    final String sql1 = "insert into EMP_MODIFIABLEVIEW3(\"comm\" BOOLEAN)"
+        + " (empno, ename, job, ^comm^) values (1, 'Arthur', 'clown', 5)";
+    final String error1 = "Unknown target column 'COMM'";
+    s.sql(sql1).fails(error1);
+
+
+    final String sql2 = "insert into EMP_MODIFIABLEVIEW3(\"comm\" BOOLEAN)"
+        + " (empno, ename, job, ^\"comm\"^) values (1, 'Arthur', 'clown', 1)";
+    final String error2 = "Cannot assign to target field 'comm' of type"
+        + " BOOLEAN from source field 'EXPR\\$3' of type INTEGER";
+    s.sql(sql2).fails(error2);
   }
 
   @Test public void testDelete() {
@@ -9924,63 +10049,100 @@ public class SqlValidatorTest extends SqlValidatorTestCase {
   }
 
   @Test public void testDeleteModifiableView() {
-    sql("delete from EMP_MODIFIABLEVIEW2 where deptno = 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW2 where deptno = 20").ok();
-    sql("delete from EMP_MODIFIABLEVIEW2 where empno = 30").ok();
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("delete from EMP_MODIFIABLEVIEW2 where deptno = 10").ok();
+    s.sql("delete from EMP_MODIFIABLEVIEW2 where deptno = 20").ok();
+    s.sql("delete from EMP_MODIFIABLEVIEW2 where empno = 30").ok();
   }
 
   @Test public void testDeleteExtendedColumnModifiableView() {
-    sql("delete from EMP_MODIFIABLEVIEW2(extra BOOLEAN) where sal > 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW2(note BOOLEAN) where note = 'fired'").ok();
+    final Sql s = sql("?").withExtendedCatalog();
+    s.sql("delete from EMP_MODIFIABLEVIEW2(extra BOOLEAN) where sal > 10")
+        .ok();
+    s.sql("delete from EMP_MODIFIABLEVIEW2(note BOOLEAN) where note = 'fired'")
+        .ok();
   }
 
   @Test public void testDeleteExtendedColumnCollision() {
-    sql("delete from emp(empno INTEGER NOT NULL) where sal > 10").ok();
+    final String sql =
+        "delete from emp(empno INTEGER NOT NULL) where sal > 10";
+    sql(sql).withExtendedCatalog().ok();
   }
 
   @Test public void testDeleteExtendedColumnModifiableViewCollision() {
-    sql("delete from EMP_MODIFIABLEVIEW2(empno INTEGER NOT NULL) where sal > 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW2(\"empno\" INTEGER) where sal > 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW2(extra BOOLEAN) where sal > 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW2(\"extra\" VARCHAR) where sal > 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW3(comm INTEGER) where sal > 10").ok();
-    sql("delete from EMP_MODIFIABLEVIEW3(\"comm\" BIGINT) where sal > 10").ok();
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "delete from EMP_MODIFIABLEVIEW2("
+        + "empno INTEGER NOT NULL) where sal > 10";
+    s.sql(sql0).ok();
+    final String sql1 = "delete from EMP_MODIFIABLEVIEW2(\"empno\" INTEGER)\n"
+        + "where sal > 10";
+    s.sql(sql1).ok();
+    final String sql2 = "delete from EMP_MODIFIABLEVIEW2(extra BOOLEAN)\n"
+        + "where sal > 10";
+    s.sql(sql2).ok();
+    final String sql3 = "delete from EMP_MODIFIABLEVIEW2(\"extra\" VARCHAR)\n"
+        + "where sal > 10";
+    s.sql(sql3).ok();
+    final String sql4 = "delete from EMP_MODIFIABLEVIEW3(comm INTEGER)\n"
+        + "where sal > 10";
+    s.sql(sql4).ok();
+    final String sql5 = "delete from EMP_MODIFIABLEVIEW3(\"comm\" BIGINT)\n"
+        + "where sal > 10";
+    s.sql(sql5).ok();
   }
 
   @Test public void testDeleteExtendedColumnFailCollision() {
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW2(^empno^ BOOLEAN) where sal > 10",
-        "Cannot assign to target field 'EMPNO' of type INTEGER NOT NULL from source field 'EMPNO' of type BOOLEAN");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW2(^empno^ INTEGER) where sal > 10",
-        "Cannot assign to target field 'EMPNO' of type INTEGER NOT NULL from source field 'EMPNO' of type INTEGER");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW2(^\"EMPNO\"^ INTEGER) where sal > 10",
-        "Cannot assign to target field 'EMPNO' of type INTEGER NOT NULL from source field 'EMPNO' of type INTEGER");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW2(^empno^ INTEGER) where sal > 10",
-        "Cannot assign to target field 'EMPNO' of type INTEGER NOT NULL from source field 'EMPNO' of type INTEGER");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "delete from EMP_MODIFIABLEVIEW2(^empno^ BOOLEAN)\n"
+        + "where sal > 10";
+    final String error0 = "Cannot assign to target field 'EMPNO' of type"
+        + " INTEGER NOT NULL from source field 'EMPNO' of type BOOLEAN";
+    s.sql(sql0).fails(error0);
+    final String sql1 = "delete from EMP_MODIFIABLEVIEW2(^empno^ INTEGER)\n"
+        + "where sal > 10";
+    final String error = "Cannot assign to target field 'EMPNO' of type"
+        + " INTEGER NOT NULL from source field 'EMPNO' of type INTEGER";
+    s.sql(sql1).fails(error);
+    final String sql2 = "delete from EMP_MODIFIABLEVIEW2(^\"EMPNO\"^ INTEGER)"
+        + " where sal > 10";
+    s.sql(sql2).fails(error);
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testDeleteExtendedColumnModifiableViewFailCollision() {
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW(^deptno^ BOOLEAN) where sal > 10",
-        "Cannot assign to target field 'DEPTNO' of type INTEGER from source field 'DEPTNO' of type BOOLEAN");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW(^\"DEPTNO\"^ BOOLEAN) where sal > 10",
-        "Cannot assign to target field 'DEPTNO' of type INTEGER from source field 'DEPTNO' of type BOOLEAN");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String sql0 = "delete from EMP_MODIFIABLEVIEW(^deptno^ BOOLEAN)\n"
+        + "where sal > 10";
+    final String error = "Cannot assign to target field 'DEPTNO' of type"
+        + " INTEGER from source field 'DEPTNO' of type BOOLEAN";
+    s.sql(sql0).fails(error);
+    final String sql1 = "delete from EMP_MODIFIABLEVIEW(^\"DEPTNO\"^ BOOLEAN)"
+        + " where sal > 10";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testDeleteExtendedColumnModifiableViewFailExtendedCollision() {
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW(^slacker^ INTEGER) where sal > 10",
-        "Cannot assign to target field 'SLACKER' of type BOOLEAN from source field 'SLACKER' of type INTEGER");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW(^\"SLACKER\"^ INTEGER) where sal > 10",
-        "Cannot assign to target field 'SLACKER' of type BOOLEAN from source field 'SLACKER' of type INTEGER");
+    final Sql s = sql("?").withExtendedCatalog();
+    final String error = "Cannot assign to target field 'SLACKER' of type"
+        + " BOOLEAN from source field 'SLACKER' of type INTEGER";
+    final String sql0 = "delete from EMP_MODIFIABLEVIEW(^slacker^ INTEGER)\n"
+        + "where sal > 10";
+    s.sql(sql0).fails(error);
+    final String sql1 = "delete from EMP_MODIFIABLEVIEW(^\"SLACKER\"^ INTEGER)"
+        + " where sal > 10";
+    s.sql(sql1).fails(error);
   }
 
   @Test public void testDeleteExtendedColumnFailDuplicate() {
-    tester.checkQueryFails("delete from emp (extra VARCHAR, ^extra^ VARCHAR)",
-        "Duplicate name 'EXTRA' in column list");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW (extra VARCHAR, ^extra^ VARCHAR)"
-            + " where extra = 'test'",
-        "Duplicate name 'EXTRA' in column list");
-    tester.checkQueryFails("delete from EMP_MODIFIABLEVIEW (extra VARCHAR, ^\"EXTRA\"^ VARCHAR)"
-            + " where extra = 'test'",
-        "Duplicate name 'EXTRA' in column list");
+    final Sql s = sql("?").withExtendedCatalog();
+    sql("delete from emp (extra VARCHAR, ^extra^ VARCHAR)")
+        .fails("Duplicate name 'EXTRA' in column list");
+    s.sql("delete from EMP_MODIFIABLEVIEW (extra VARCHAR, ^extra^ VARCHAR)"
+            + " where extra = 'test'")
+        .fails("Duplicate name 'EXTRA' in column list");
+    s.sql("delete from EMP_MODIFIABLEVIEW (extra VARCHAR, ^\"EXTRA\"^ VARCHAR)"
+            + " where extra = 'test'")
+        .fails("Duplicate name 'EXTRA' in column list");
   }
 
   /** Test case for

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/core/src/test/java/org/apache/calcite/test/SqlValidatorTestCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTestCase.java b/core/src/test/java/org/apache/calcite/test/SqlValidatorTestCase.java
index c1833f0..12ae488 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTestCase.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTestCase.java
@@ -16,6 +16,7 @@
  */
 package org.apache.calcite.test;
 
+import org.apache.calcite.adapter.java.JavaTypeFactory;
 import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.runtime.CalciteContextException;
 import org.apache.calcite.sql.SqlCollation;
@@ -23,10 +24,13 @@ import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.parser.SqlParseException;
 import org.apache.calcite.sql.parser.SqlParserUtil;
 import org.apache.calcite.sql.test.DefaultSqlTestFactory;
+import org.apache.calcite.sql.test.DelegatingSqlTestFactory;
+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.sql.test.SqlTests;
 import org.apache.calcite.sql.validate.SqlConformance;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
 import org.apache.calcite.sql.validate.SqlMonotonicity;
 import org.apache.calcite.sql.validate.SqlValidator;
 import org.apache.calcite.util.TestUtil;
@@ -61,6 +65,24 @@ public class SqlValidatorTestCase {
       Pattern.compile(
           "(?s)From line ([0-9]+), column ([0-9]+) to line ([0-9]+), column ([0-9]+): (.*)");
 
+  static final SqlTesterImpl EXTENDED_CATALOG_TESTER =
+      new SqlTesterImpl(
+        new DelegatingSqlTestFactory(DefaultSqlTestFactory.INSTANCE) {
+          @Override public MockCatalogReader createCatalogReader(
+              SqlTestFactory factory, JavaTypeFactory typeFactory) {
+            return super.createCatalogReader(this, typeFactory).init2();
+          }
+        });
+
+  static final SqlTesterImpl EXTENDED_CATALOG_TESTER_2003 =
+      new SqlTesterImpl(
+        new DelegatingSqlTestFactory(DefaultSqlTestFactory.INSTANCE) {
+          @Override public MockCatalogReader createCatalogReader(
+              SqlTestFactory factory, JavaTypeFactory typeFactory) {
+            return super.createCatalogReader(this, typeFactory).init2();
+          }
+        }).withConformance(SqlConformanceEnum.PRAGMATIC_2003);
+
   //~ Instance fields --------------------------------------------------------
 
   protected SqlTester tester;
@@ -541,6 +563,18 @@ public class SqlValidatorTestCase {
       return new Sql(tester, sql);
     }
 
+    public Sql sql(String sql) {
+      return new Sql(tester, sql);
+    }
+
+    Sql withExtendedCatalog() {
+      return tester(EXTENDED_CATALOG_TESTER);
+    }
+
+    Sql withExtendedCatalog2003() {
+      return tester(EXTENDED_CATALOG_TESTER_2003);
+    }
+
     Sql ok() {
       tester.assertExceptionIsThrown(sql, null);
       return this;

http://git-wip-us.apache.org/repos/asf/calcite/blob/df826434/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
index aa5ed59..131ea6e 100644
--- a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
@@ -2431,7 +2431,8 @@ LogicalProject(EXPR$0=[+($0, $2)])
     </TestCase>
     <TestCase name="testModifiableViewExtend">
         <Resource name="sql">
-            <![CDATA[select * from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)]]>
+            <![CDATA[select *
+from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[
@@ -2442,7 +2443,8 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$
     </TestCase>
     <TestCase name="testModifiableViewExtendSubset">
         <Resource name="sql">
-            <![CDATA[select x, empno from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)]]>
+            <![CDATA[select x, empno
+from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[
@@ -2453,7 +2455,8 @@ LogicalProject(X=[$8], EMPNO=[$0])
     </TestCase>
     <TestCase name="testModifiableViewExtendExpression">
         <Resource name="sql">
-            <![CDATA[select empno + x from EMP_MODIFIABLEVIEW extend (x int not null)]]>
+            <![CDATA[select empno + x
+from EMP_MODIFIABLEVIEW extend (x int not null)]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[
@@ -2464,7 +2467,8 @@ LogicalProject(EXPR$0=[+($0, $8)])
     </TestCase>
     <TestCase name="testSelectModifiableViewConstraint">
         <Resource name="sql">
-            <![CDATA[select deptno from EMP_MODIFIABLEVIEW2 where deptno = ?]]>
+            <![CDATA[select deptno from EMP_MODIFIABLEVIEW2
+where deptno = ?]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[
@@ -2474,7 +2478,7 @@ LogicalProject(DEPTNO=[$3])
 ]]>
         </Resource>
     </TestCase>
-    <TestCase name="testModifiableViewDDLExtend">
+    <TestCase name="testModifiableViewDdlExtend">
         <Resource name="sql">
             <![CDATA[select extra from EMP_MODIFIABLEVIEW2]]>
         </Resource>
@@ -3597,7 +3601,8 @@ LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[DEL
     </TestCase>
     <TestCase name="testDeleteBindExtendedColumnModifiableView">
         <Resource name="sql">
-            <![CDATA[delete from EMP_MODIFIABLEVIEW2(note VARCHAR) where note = ?]]>
+            <![CDATA[delete from EMP_MODIFIABLEVIEW2(note VARCHAR)
+where note = ?]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[
@@ -3798,7 +3803,8 @@ LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[UPDATE], up
     </TestCase>
     <TestCase name="testUpdateModifiableView">
         <Resource name="sql">
-            <![CDATA[update EMP_MODIFIABLEVIEW2 set sal = sal + 5000 where slacker = false]]>
+            <![CDATA[update EMP_MODIFIABLEVIEW2
+set sal = sal + 5000 where slacker = false]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[
@@ -3811,7 +3817,9 @@ LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[UPD
     </TestCase>
     <TestCase name="testUpdateExtendedColumnModifiableView">
         <Resource name="sql">
-            <![CDATA[update EMP_MODIFIABLEVIEW2(updated TIMESTAMP) set updated = timestamp '2017-03-12 13:03:05', sal = sal + 5000 where slacker = false]]>
+            <![CDATA[update EMP_MODIFIABLEVIEW2(updated TIMESTAMP)
+set updated = timestamp '2017-03-12 13:03:05', sal = sal + 5000
+where slacker = false]]>
         </Resource>
         <Resource name="plan">
             <![CDATA[


Mime
View raw message