calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [1/2] incubator-calcite git commit: [CALCITE-885] Add Oracle test environment
Date Tue, 22 Sep 2015 00:20:25 GMT
Repository: incubator-calcite
Updated Branches:
  refs/heads/master 02cfd7fda -> beb3b3bcf


[CALCITE-885] Add Oracle test environment


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

Branch: refs/heads/master
Commit: 3f8363855985106cccefa339dd12a3f86dacabb4
Parents: 02cfd7f
Author: Julian Hyde <jhyde@apache.org>
Authored: Thu Sep 17 13:30:36 2015 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Mon Sep 21 15:44:25 2015 -0700

----------------------------------------------------------------------
 core/pom.xml                                    |  52 +++++++
 .../calcite/adapter/jdbc/JdbcImplementor.java   |  17 +++
 .../calcite/sql/type/SqlTypeFactoryImpl.java    |   5 +-
 .../org/apache/calcite/test/CalciteAssert.java  | 142 +++++++++++++------
 .../org/apache/calcite/test/ConnectionSpec.java |   6 +-
 .../test/JdbcFrontJdbcBackLinqMiddleTest.java   |   6 +-
 .../calcite/test/JdbcFrontJdbcBackTest.java     |   4 +-
 .../java/org/apache/calcite/test/JdbcTest.java  |  49 ++++---
 .../org/apache/calcite/test/LatticeTest.java    |  19 ++-
 .../org/apache/calcite/test/StreamTest.java     |   8 +-
 pom.xml                                         |   2 -
 11 files changed, 231 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index e65d748..65adb3e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -233,6 +233,7 @@ limitations under the License.
               <!-- ignore "unused but declared" warnings -->
               <ignoredUnusedDeclaredDependencies>
                 <ignoredUnusedDeclaredDependency>com.h2database:h2</ignoredUnusedDeclaredDependency>
+                <ignoredUnusedDeclaredDependency>com.oracle:ojdbc6</ignoredUnusedDeclaredDependency>
                 <ignoredUnusedDeclaredDependency>mysql:mysql-connector-java</ignoredUnusedDeclaredDependency>
                 <ignoredUnusedDeclaredDependency>net.hydromatic:scott-data-hsqldb</ignoredUnusedDeclaredDependency>
                 <ignoredUnusedDeclaredDependency>net.hydromatic:foodmart-data-hsqldb</ignoredUnusedDeclaredDependency>
@@ -340,6 +341,57 @@ limitations under the License.
       </build>
     </profile>
     <profile>
+      <id>it-oracle</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-failsafe-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>failsafe-integration-test</id>
+                <!-- Disable the integration test inherited from the parent pom
+                     so that we can run multiple tests, one per database. -->
+                <phase>none</phase>
+              </execution>
+              <execution>
+                <id>failsafe-test-oracle</id>
+                <goals>
+                  <goal>integration-test</goal>
+                </goals>
+                <phase>integration-test</phase>
+                <configuration>
+                  <includes>
+                    <include>org/apache/calcite/test/JdbcAdapterTest.java</include>
+                    <include>org/apache/calcite/test/JdbcTest.java</include>
+                  </includes>
+                  <systemPropertyVariables>
+                    <calcite.test.db>oracle</calcite.test.db>
+                  </systemPropertyVariables>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+      <dependencies>
+        <dependency>
+          <!-- Oracle's driver is not open source. Install the jar in your
+               local maven repository as follows:
+
+               $ cd $ORACLE_HOME/jdbc/lib
+               $ mvn install:install-file -DgroupId=com.oracle
+                 -DartifactId=ojdbc6 -Dversion=11.2.0.2.0 -Dpackaging=jar
+                 -Dfile=ojdbc6.jar -DgeneratePom=true
+          -->
+          <groupId>com.oracle</groupId>
+          <artifactId>ojdbc6</artifactId>
+          <version>11.2.0.2.0</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+    </profile>
+    <profile>
       <!-- CALCITE-539: workaround for MSHARED-394: Avoid rewrite of
       destination in DefaultMavenFileFilter#filterFile when producing
       the same contents -->

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
index 7955a3a..aa6c041 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
@@ -34,8 +34,11 @@ import org.apache.calcite.sql.SqlBinaryOperator;
 import org.apache.calcite.sql.SqlCall;
 import org.apache.calcite.sql.SqlDataTypeSpec;
 import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlFunction;
+import org.apache.calcite.sql.SqlFunctionCategory;
 import org.apache.calcite.sql.SqlIdentifier;
 import org.apache.calcite.sql.SqlJoin;
+import org.apache.calcite.sql.SqlKind;
 import org.apache.calcite.sql.SqlLiteral;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.SqlNodeList;
@@ -48,6 +51,7 @@ import org.apache.calcite.sql.fun.SqlStdOperatorTable;
 import org.apache.calcite.sql.fun.SqlSumEmptyIsZeroAggFunction;
 import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.type.BasicSqlType;
+import org.apache.calcite.sql.type.ReturnTypes;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.sql.validate.SqlValidatorUtil;
 import org.apache.calcite.util.Pair;
@@ -70,6 +74,13 @@ import java.util.Set;
 public class JdbcImplementor {
   public static final SqlParserPos POS = SqlParserPos.ZERO;
 
+  /** Oracle's {@code SUBSTR} function.
+   * Oracle does not support {@link SqlStdOperatorTable#SUBSTRING}. */
+  public static final SqlFunction ORACLE_SUBSTR =
+      new SqlFunction("SUBSTR", SqlKind.OTHER_FUNCTION,
+          ReturnTypes.ARG0_NULLABLE_VARYING, null, null,
+          SqlFunctionCategory.STRING);
+
   final SqlDialect dialect;
   private final Set<String> aliasSet = new LinkedHashSet<String>();
 
@@ -219,6 +230,12 @@ public class JdbcImplementor {
           // SqlCall requires exactly 2. So, convert to a left-deep binary tree.
           return createLeftCall(op, nodeList);
         }
+        if (op == SqlStdOperatorTable.SUBSTRING) {
+          switch (dialect.getDatabaseProduct()) {
+          case ORACLE:
+            return ORACLE_SUBSTR.createCall(new SqlNodeList(nodeList, POS));
+          }
+        }
         return op.createCall(new SqlNodeList(nodeList, POS));
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java
index 3003269..a37369c 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeFactoryImpl.java
@@ -365,7 +365,10 @@ public class SqlTypeFactoryImpl extends RelDataTypeFactoryImpl {
 
               int precision = dout + scale;
               assert precision <= maxPrecision;
-              assert precision > 0;
+              assert precision > 0
+                  || (resultType.getSqlTypeName() == SqlTypeName.DECIMAL
+                      && precision == 0
+                      && scale == 0);
 
               resultType =
                   createSqlType(

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
index 3d0a0dc..7e96dba 100644
--- a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
+++ b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
@@ -244,11 +244,16 @@ public class CalciteAssert {
   }
 
   static Function<ResultSet, Void> checkResult(final String expected) {
+    return checkResult(expected, new ResultSetFormatter());
+  }
+
+  static Function<ResultSet, Void> checkResult(final String expected,
+      final ResultSetFormatter resultSetFormatter) {
     return new Function<ResultSet, Void>() {
       public Void apply(ResultSet resultSet) {
         try {
-          final String resultString = CalciteAssert.toString(resultSet);
-          assertEquals(expected, Util.toLinux(resultString));
+          resultSetFormatter.resultSet(resultSet);
+          assertEquals(expected, Util.toLinux(resultSetFormatter.string()));
           return null;
         } catch (SQLException e) {
           throw new RuntimeException(e);
@@ -525,31 +530,9 @@ public class CalciteAssert {
     }
   }
 
+  /** Converts a {@link ResultSet} to a string. */
   static String toString(ResultSet resultSet) throws SQLException {
-    final StringBuilder buf = new StringBuilder();
-    final ResultSetMetaData metaData = resultSet.getMetaData();
-    while (resultSet.next()) {
-      rowToString(resultSet, buf, metaData).append("\n");
-    }
-    return buf.toString();
-  }
-
-  /** Converts one row to a string. */
-  static StringBuilder rowToString(ResultSet resultSet, StringBuilder buf,
-      ResultSetMetaData metaData) throws SQLException {
-    int n = metaData.getColumnCount();
-    if (n > 0) {
-      for (int i = 1;; i++) {
-        buf.append(metaData.getColumnLabel(i))
-            .append("=")
-            .append(resultSet.getString(i));
-        if (i == n) {
-          break;
-        }
-        buf.append("; ");
-      }
-    }
-    return buf;
+    return new ResultSetFormatter().resultSet(resultSet).string();
   }
 
   static int countRows(ResultSet resultSet) throws SQLException {
@@ -562,13 +545,7 @@ public class CalciteAssert {
 
   static Collection<String> toStringList(ResultSet resultSet,
       Collection<String> list) throws SQLException {
-    final StringBuilder buf = new StringBuilder();
-    while (resultSet.next()) {
-      rowToString(resultSet, buf, resultSet.getMetaData());
-      list.add(buf.toString());
-      buf.setLength(0);
-    }
-    return list;
+    return new ResultSetFormatter().toStringList(resultSet, list);
   }
 
   static ImmutableMultiset<String> toSet(ResultSet resultSet)
@@ -632,14 +609,15 @@ public class CalciteAssert {
       dataSource = JdbcSchema.dataSource(cs.url, cs.driver, cs.username,
           cs.password);
       return rootSchema.add("JDBC_SCOTT",
-          JdbcSchema.create(rootSchema, "JDBC_SCOTT", dataSource, null, null));
+          JdbcSchema.create(rootSchema, "JDBC_SCOTT", dataSource, cs.catalog,
+              cs.schema));
     case JDBC_FOODMART:
       cs = DB.foodmart;
       dataSource =
           JdbcSchema.dataSource(cs.url, cs.driver, cs.username, cs.password);
       return rootSchema.add("foodmart",
-          JdbcSchema.create(rootSchema, "foodmart", dataSource, null,
-              "foodmart"));
+          JdbcSchema.create(rootSchema, "foodmart", dataSource, cs.catalog,
+              cs.schema));
     case JDBC_FOODMART_WITH_LATTICE:
       foodmart = rootSchema.getSubSchema("foodmart");
       if (foodmart == null) {
@@ -1149,6 +1127,30 @@ public class CalciteAssert {
       return returns(checkResult(expected));
     }
 
+    /** Simlar to {@link #returns}, but trims a few values before comparing. */
+    public AssertQuery returns2(final String expected) {
+      return returns(
+          checkResult(expected,
+              new ResultSetFormatter() {
+                @Override protected String adjustValue(String s) {
+                  if (s != null) {
+                    if (s.contains(".")) {
+                      while (s.endsWith("0")) {
+                        s = s.substring(0, s.length() - 1);
+                      }
+                      if (s.endsWith(".")) {
+                        s = s.substring(0, s.length() - 1);
+                      }
+                    }
+                    if (s.endsWith(" 00:00:00")) {
+                      s = s.substring(0, s.length() - " 00:00:00".length());
+                    }
+                  }
+                  return s;
+                }
+              }));
+    }
+
     public AssertQuery returnsValue(String expected) {
       return returns(checkResultValue(expected));
     }
@@ -1489,20 +1491,23 @@ public class CalciteAssert {
   public enum DatabaseInstance {
     HSQLDB(
         new ConnectionSpec(FoodmartHsqldb.URI, "FOODMART", "FOODMART",
-            "org.hsqldb.jdbcDriver"),
+            "org.hsqldb.jdbcDriver", "foodmart"),
         new ConnectionSpec(ScottHsqldb.URI, ScottHsqldb.USER,
-            ScottHsqldb.PASSWORD, "org.hsqldb.jdbcDriver")),
+            ScottHsqldb.PASSWORD, "org.hsqldb.jdbcDriver", "SCOTT")),
     H2(
         new ConnectionSpec("jdbc:h2:" + getDataSetPath()
             + "/h2/target/foodmart;user=foodmart;password=foodmart",
-            "foodmart", "foodmart", "org.h2.Driver"), null),
+            "foodmart", "foodmart", "org.h2.Driver", "foodmart"), null),
     MYSQL(
         new ConnectionSpec("jdbc:mysql://localhost/foodmart", "foodmart",
-            "foodmart", "com.mysql.jdbc.Driver"), null),
+            "foodmart", "com.mysql.jdbc.Driver", "foodmart"), null),
+    ORACLE(
+        new ConnectionSpec("jdbc:oracle:thin:@localhost:1521:XE", "foodmart",
+            "foodmart", "oracle.jdbc.OracleDriver", "FOODMART"), null),
     POSTGRESQL(
         new ConnectionSpec(
             "jdbc:postgresql://localhost/foodmart?user=foodmart&password=foodmart&searchpath=foodmart",
-            "foodmart", "foodmart", "org.postgresql.Driver"), null);
+            "foodmart", "foodmart", "org.postgresql.Driver", "foodmart"), null);
 
     public final ConnectionSpec foodmart;
     public final ConnectionSpec scott;
@@ -1542,6 +1547,61 @@ public class CalciteAssert {
     LINGUAL,
     POST
   }
+
+  /** Converts a {@link ResultSet} to string. */
+  static class ResultSetFormatter {
+    final StringBuilder buf = new StringBuilder();
+
+    public ResultSetFormatter resultSet(ResultSet resultSet)
+        throws SQLException {
+      final ResultSetMetaData metaData = resultSet.getMetaData();
+      while (resultSet.next()) {
+        rowToString(resultSet, metaData);
+        buf.append("\n");
+      }
+      return this;
+    }
+
+    /** Converts one row to a string. */
+    ResultSetFormatter rowToString(ResultSet resultSet,
+        ResultSetMetaData metaData) throws SQLException {
+      int n = metaData.getColumnCount();
+      if (n > 0) {
+        for (int i = 1;; i++) {
+          buf.append(metaData.getColumnLabel(i))
+              .append("=")
+              .append(adjustValue(resultSet.getString(i)));
+          if (i == n) {
+            break;
+          }
+          buf.append("; ");
+        }
+      }
+      return this;
+    }
+
+    protected String adjustValue(String string) {
+      return string;
+    }
+
+    public Collection<String> toStringList(ResultSet resultSet,
+        Collection<String> list) throws SQLException {
+      final ResultSetMetaData metaData = resultSet.getMetaData();
+      while (resultSet.next()) {
+        rowToString(resultSet, metaData);
+        list.add(buf.toString());
+        buf.setLength(0);
+      }
+      return list;
+    }
+
+    /** Flushes the buffer and returns its previous contents. */
+    public String string() {
+      String s = buf.toString();
+      buf.setLength(0);
+      return s;
+    }
+  }
 }
 
 // End CalciteAssert.java

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/ConnectionSpec.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/ConnectionSpec.java b/core/src/test/java/org/apache/calcite/test/ConnectionSpec.java
index 4142083..5fb98cd 100644
--- a/core/src/test/java/org/apache/calcite/test/ConnectionSpec.java
+++ b/core/src/test/java/org/apache/calcite/test/ConnectionSpec.java
@@ -24,13 +24,17 @@ public class ConnectionSpec {
   public final String username;
   public final String password;
   public final String driver;
+  public final String schema;
+  public final String catalog;
 
   public ConnectionSpec(String url, String username, String password,
-      String driver) {
+      String driver, String schema) {
     this.url = url;
     this.username = username;
     this.password = password;
     this.driver = driver;
+    this.schema = schema;
+    this.catalog = null;
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackLinqMiddleTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackLinqMiddleTest.java
b/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackLinqMiddleTest.java
index e6235de..ed09ffb 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackLinqMiddleTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackLinqMiddleTest.java
@@ -162,9 +162,9 @@ public class JdbcFrontJdbcBackLinqMiddleTest {
             + "  on s.\"customer_id\" = c.\"customer_id\"\n"
             + "group by c.\"state_province\"\n"
             + "order by c.\"state_province\"")
-        .returns("EXPR$0=24442; state_province=CA; S=74748.0000\n"
-            + "EXPR$0=21611; state_province=OR; S=67659.0000\n"
-            + "EXPR$0=40784; state_province=WA; S=124366.0000\n");
+        .returns2("EXPR$0=24442; state_province=CA; S=74748\n"
+            + "EXPR$0=21611; state_province=OR; S=67659\n"
+            + "EXPR$0=40784; state_province=WA; S=124366\n");
   }
 
   @Test public void testCompositeGroupBy() {

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackTest.java b/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackTest.java
index ac99ef6..5cea310 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcFrontJdbcBackTest.java
@@ -158,8 +158,8 @@ public class JdbcFrontJdbcBackTest {
             + "from \"sales_fact_1997\" as \"sales_fact_1997\""
             + "where \"product_id\" = 1\n"
             + "and \"time_id\" < 400")
-        .returns("c0=11.4000\n"
-            + "c0=8.5500\n");
+        .returns2("c0=11.4\n"
+            + "c0=8.55\n");
   }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index a024686..43c9ae9 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -196,12 +196,12 @@ public class JdbcTest {
   public static final String FOODMART_SCHEMA = "     {\n"
       + "       type: 'jdbc',\n"
       + "       name: 'foodmart',\n"
-      + "       jdbcDriver: '" + CalciteAssert.DB.foodmart.driver + "',\n"
-      + "       jdbcUser: '" + CalciteAssert.DB.foodmart.username + "',\n"
-      + "       jdbcPassword: '" + CalciteAssert.DB.foodmart.password + "',\n"
-      + "       jdbcUrl: '" + CalciteAssert.DB.foodmart.url + "',\n"
-      + "       jdbcCatalog: null,\n"
-      + "       jdbcSchema: 'foodmart'\n"
+      + "       jdbcDriver: " + q(CalciteAssert.DB.foodmart.driver) + ",\n"
+      + "       jdbcUser: " + q(CalciteAssert.DB.foodmart.username) + ",\n"
+      + "       jdbcPassword: " + q(CalciteAssert.DB.foodmart.password) + ",\n"
+      + "       jdbcUrl: " + q(CalciteAssert.DB.foodmart.url) + ",\n"
+      + "       jdbcCatalog: " + q(CalciteAssert.DB.foodmart.catalog) + ",\n"
+      + "       jdbcSchema: " + q(CalciteAssert.DB.foodmart.schema) + "\n"
       + "     }\n";
 
   public static final String FOODMART_MODEL = "{\n"
@@ -219,12 +219,12 @@ public class JdbcTest {
   public static final String SCOTT_SCHEMA = "     {\n"
       + "       type: 'jdbc',\n"
       + "       name: 'SCOTT',\n"
-      + "       jdbcDriver: '" + SCOTT.driver + "',\n"
-      + "       jdbcUser: '" + SCOTT.username + "',\n"
-      + "       jdbcPassword: '" + SCOTT.password + "',\n"
-      + "       jdbcUrl: '" + SCOTT.url + "',\n"
-      + "       jdbcCatalog: null,\n"
-      + "       jdbcSchema: 'SCOTT'\n"
+      + "       jdbcDriver: " + q(SCOTT.driver) + ",\n"
+      + "       jdbcUser: " + q(SCOTT.username) + ",\n"
+      + "       jdbcPassword: " + q(SCOTT.password) + ",\n"
+      + "       jdbcUrl: " + q(SCOTT.url) + ",\n"
+      + "       jdbcCatalog: " + q(SCOTT.catalog) + ",\n"
+      + "       jdbcSchema: " + q(SCOTT.schema) + "\n"
       + "     }\n";
 
   public static final String SCOTT_MODEL = "{\n"
@@ -265,6 +265,10 @@ public class JdbcTest {
       + "(8,1,4))\n"
       + " as t(rn,val,expected)";
 
+  private static String q(String s) {
+    return s == null ? "null" : "'" + s + "'";
+  }
+
   public static List<Pair<String, String>> getFoodmartQueries() {
     return FOODMART_QUERIES;
   }
@@ -1742,7 +1746,8 @@ public class JdbcTest {
             + "  where \"position_title\" = 'VP Country Manager'\n"
             + "  and \"birth_date\" < DATE '1950-01-01'\n"
             + "  and \"gender\" = 'F')")
-        .returns("C=1\n");
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
+        .returns2("C=1\n");
   }
 
   /** Tests a timestamp literal against JDBC data source. */
@@ -2456,8 +2461,8 @@ public class JdbcTest {
         .with(config)
         .query(
             "select \"hire_date\", \"end_date\", \"birth_date\" from \"foodmart\".\"employee\"
where \"employee_id\" = 1")
-        .returns(
-            "hire_date=1994-12-01 00:00:00; end_date=null; birth_date=1961-08-26\n");
+        .returns2(
+            "hire_date=1994-12-01; end_date=null; birth_date=1961-08-26\n");
   }
 
   @Test public void testReuseExpressionWhenNullChecking() {
@@ -2763,6 +2768,7 @@ public class JdbcTest {
     CalciteAssert.that()
         .with(CalciteAssert.Config.FOODMART_CLONE)
         .query(s)
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .explainContains(""
             + "EnumerableAggregate(group=[{0}], m0=[COUNT($1)])\n"
             + "  EnumerableAggregate(group=[{1, 3}])\n"
@@ -4308,11 +4314,13 @@ public class JdbcTest {
     CalciteAssert.model(FOODMART_MODEL)
         .query("select count(*) as c from \"customer\" "
             + "where \"lname\" = 'this string is longer than 30 characters'")
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .returns("C=0\n");
 
     CalciteAssert.model(FOODMART_MODEL)
         .query("select count(*) as c from \"customer\" "
             + "where cast(\"customer_id\" as char(20)) = 'this string is longer than 30 characters'")
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .returns("C=0\n");
   }
 
@@ -4577,6 +4585,12 @@ public class JdbcTest {
   }
 
   @Test public void testRunMisc() throws Exception {
+    switch (CalciteAssert.DB) {
+    case ORACLE:
+      // There are formatting differences (e.g. "4.000" vs "4") when using
+      // Oracle as the JDBC data source.
+      return;
+    }
     checkRun("sql/misc.oq");
   }
 
@@ -5832,12 +5846,11 @@ public class JdbcTest {
   }
 
   /** Tests accessing a date as a string in a JDBC source whose type is DATE. */
-  @Test
-  public void testGetDateAsString() throws Exception {
+  @Test public void testGetDateAsString() throws Exception {
     CalciteAssert.that()
       .with(CalciteAssert.Config.JDBC_FOODMART)
       .query("select min(\"date\") mindate from \"foodmart\".\"currency\"")
-      .returns("MINDATE=1997-01-01\n");
+      .returns2("MINDATE=1997-01-01\n");
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/LatticeTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/LatticeTest.java b/core/src/test/java/org/apache/calcite/test/LatticeTest.java
index b1155f0..d4f522a 100644
--- a/core/src/test/java/org/apache/calcite/test/LatticeTest.java
+++ b/core/src/test/java/org/apache/calcite/test/LatticeTest.java
@@ -357,13 +357,14 @@ public class LatticeTest {
             + "from \"foodmart\".\"sales_fact_1997\" as s\n"
             + "join \"foodmart\".\"time_by_day\" as t using (\"time_id\")\n"
             + "group by t.\"the_year\"")
-      .enableMaterializations(true)
-      .explainContains(""
-          + "EnumerableCalc(expr#0..3=[{inputs}], expr#4=[10], expr#5=[*($t3, $t4)], proj#0..2=[{exprs}],
US=[$t5])\n"
-          + "  EnumerableAggregate(group=[{0}], C=[$SUM0($2)], Q=[MIN($1)], agg#2=[$SUM0($4)])\n"
-          + "    EnumerableTableScan(table=[[adhoc, m{27, 31}")
-      .returnsUnordered("the_year=1997; C=86837; Q=Q1; US=2667730.0000")
-      .sameResultWithMaterializationsDisabled();
+        .enableMaterializations(true)
+        .explainContains(""
+            + "EnumerableCalc(expr#0..3=[{inputs}], expr#4=[10], expr#5=[*($t3, $t4)], proj#0..2=[{exprs}],
US=[$t5])\n"
+            + "  EnumerableAggregate(group=[{0}], C=[$SUM0($2)], Q=[MIN($1)], agg#2=[$SUM0($4)])\n"
+            + "    EnumerableTableScan(table=[[adhoc, m{27, 31}")
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
+        .returnsUnordered("the_year=1997; C=86837; Q=Q1; US=2667730.0000")
+        .sameResultWithMaterializationsDisabled();
   }
 
   /** Tests a model that uses an algorithm to generate an initial set of
@@ -467,6 +468,7 @@ public class LatticeTest {
         .query("select sum(\"unit_sales\") as s\n"
             + "from \"foodmart\".\"sales_fact_1997\"")
         .enableMaterializations(true)
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .returnsUnordered("S=266773.0000");
   }
 
@@ -487,6 +489,7 @@ public class LatticeTest {
         .withHook(Hook.CREATE_MATERIALIZATION, handler)
         .enableMaterializations(true)
         .explainContains("EnumerableTableScan(table=[[adhoc, m{}]])")
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .returnsUnordered("S=266773.0000; C=86837");
     assertThat(mats.toString(), mats.size(), equalTo(2));
 
@@ -495,6 +498,7 @@ public class LatticeTest {
         + "from \"foodmart\".\"sales_fact_1997\"")
         .withHook(Hook.CREATE_MATERIALIZATION, handler)
         .enableMaterializations(true)
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .returnsUnordered("S=266773.0000");
     assertThat(mats.toString(), mats.size(), equalTo(2));
   }
@@ -507,6 +511,7 @@ public class LatticeTest {
             + "group by \"product_id\"\n"
             + "order by 1 desc limit 1")
         .enableMaterializations(true)
+        .enable(CalciteAssert.DB != CalciteAssert.DatabaseInstance.ORACLE)
         .returnsUnordered("C=267.0000");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/core/src/test/java/org/apache/calcite/test/StreamTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/StreamTest.java b/core/src/test/java/org/apache/calcite/test/StreamTest.java
index 5a6291b..269a2e5 100644
--- a/core/src/test/java/org/apache/calcite/test/StreamTest.java
+++ b/core/src/test/java/org/apache/calcite/test/StreamTest.java
@@ -217,15 +217,15 @@ public class StreamTest {
     return new Function<ResultSet, Void>() {
       public Void apply(ResultSet input) {
         try {
-          final StringBuilder buf = new StringBuilder();
+          final CalciteAssert.ResultSetFormatter formatter =
+              new CalciteAssert.ResultSetFormatter();
           final ResultSetMetaData metaData = input.getMetaData();
           for (String expectedRow : rowList) {
             if (!input.next()) {
               throw new AssertionError("input ended too soon");
             }
-            CalciteAssert.rowToString(input, buf, metaData);
-            String actualRow = buf.toString();
-            buf.setLength(0);
+            formatter.rowToString(input, metaData);
+            String actualRow = formatter.string();
             assertThat(actualRow, equalTo(expectedRow));
           }
           return null;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/3f836385/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6c46e8b..4830e62 100644
--- a/pom.xml
+++ b/pom.xml
@@ -165,7 +165,6 @@ limitations under the License.
         <groupId>com.h2database</groupId>
         <artifactId>h2</artifactId>
         <version>1.4.185</version>
-        <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>javax.servlet</groupId>
@@ -236,7 +235,6 @@ limitations under the License.
         <groupId>org.postgresql</groupId>
         <artifactId>postgresql</artifactId>
         <version>9.3-1102-jdbc3</version>
-        <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>org.scala-lang</groupId>


Mime
View raw message