You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/04/17 20:35:42 UTC

[3/8] incubator-calcite git commit: Add PostgreSQL integration test

Add PostgreSQL integration test


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

Branch: refs/heads/master
Commit: 4c0cf674699ea15f8e3753dce44c83e15eb117d6
Parents: 1fd18a3
Author: Vladimir Sitnikov <si...@gmail.com>
Authored: Tue Feb 10 12:50:15 2015 +0300
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Apr 16 02:21:43 2015 -0700

----------------------------------------------------------------------
 core/pom.xml                                        | 16 ++++++++++++++++
 .../org/apache/calcite/adapter/jdbc/JdbcSchema.java |  8 +++++++-
 .../java/org/apache/calcite/sql/SqlDialect.java     |  1 +
 .../java/org/apache/calcite/test/CalciteAssert.java | 13 ++++++++-----
 pom.xml                                             | 12 ++++++++++++
 5 files changed, 44 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4c0cf674/core/pom.xml
----------------------------------------------------------------------
diff --git a/core/pom.xml b/core/pom.xml
index 479aca6..010ed8b 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -284,6 +284,22 @@ limitations under the License.
                   </systemPropertyVariables>
                 </configuration>
               </execution>
+              <execution>
+                <id>failsafe-test-postgresql</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>postgresql</calcite.test.db>
+                  </systemPropertyVariables>
+                </configuration>
+              </execution>
             </executions>
           </plugin>
         </plugins>

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4c0cf674/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
index cce3fcc..6d5b3cd 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcSchema.java
@@ -201,8 +201,14 @@ public class JdbcSchema implements Schema {
         // returned by Phoenix among others, maps to TableType.SYSTEM_TABLE.
         // We know enum constants are upper-case without spaces, so we can't
         // make things worse.
+        // PostgreSQL returns tableTypeName==null for pg_toast* tables
+        // This can happen if you start JdbcSchema off a "public" PG schema
+        // The tables are not designed to be queried by users, however we do
+        // not filter them as we keep all the other table types.
         final String tableTypeName2 =
-            tableTypeName.toUpperCase().replace(' ', '_');
+            tableTypeName == null
+            ? null
+            : tableTypeName.toUpperCase().replace(' ', '_');
         final TableType tableType =
             Util.enumVal(TableType.class, tableTypeName2);
         final JdbcTable table =

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4c0cf674/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlDialect.java b/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
index 931d463..8f85b1d 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlDialect.java
@@ -409,6 +409,7 @@ public class SqlDialect {
     case MYSQL:
     case HSQLDB:
     case PHOENIX:
+    case POSTGRESQL:
       return false;
     default:
       return true;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4c0cf674/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 f221b02..89fbba2 100644
--- a/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
+++ b/core/src/test/java/org/apache/calcite/test/CalciteAssert.java
@@ -103,10 +103,9 @@ public class CalciteAssert {
    * failures.  To run against MySQL, specify '-Dcalcite.test.db=mysql' on the
    * java command line. */
   public static final DatabaseInstance DB =
-      Util.first(System.getProperty("calcite.test.db"), "hsqldb")
-          .equals("mysql")
-          ? DatabaseInstance.MYSQL
-          : DatabaseInstance.HSQLDB;
+      DatabaseInstance.valueOf(
+          Util.first(System.getProperty("calcite.test.db"), "HSQLDB")
+              .toUpperCase());
 
   /** Whether to enable slow tests. Default is false. */
   public static final boolean ENABLE_SLOW =
@@ -1486,7 +1485,11 @@ public class CalciteAssert {
             ScottHsqldb.PASSWORD, "org.hsqldb.jdbcDriver")),
     MYSQL(
         new ConnectionSpec("jdbc:mysql://localhost/foodmart", "foodmart",
-            "foodmart", "com.mysql.jdbc.Driver"), null);
+            "foodmart", "com.mysql.jdbc.Driver"), null),
+    POSTGRESQL(
+        new ConnectionSpec(
+            "jdbc:postgresql://localhost/foodmart?user=foodmart&password=foodmart&searchpath=foodmart",
+            "foodmart", "foodmart", "org.postgresql.Driver"), null);
 
     public final ConnectionSpec foodmart;
     public final ConnectionSpec scott;

http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/4c0cf674/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1b9f832..ea2b0b5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -217,6 +217,12 @@ limitations under the License.
         <version>3.2</version>
       </dependency>
       <dependency>
+        <groupId>org.postgresql</groupId>
+        <artifactId>postgresql</artifactId>
+        <version>9.3-1102-jdbc3</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>org.scala-lang</groupId>
         <artifactId>scala-library</artifactId>
         <version>2.10.3</version>
@@ -242,6 +248,12 @@ limitations under the License.
         <version>2.3.1</version>
       </dependency>
       <dependency>
+        <groupId>com.h2database</groupId>
+        <artifactId>h2</artifactId>
+        <version>1.4.185</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>org.incava</groupId>
         <artifactId>java-diff</artifactId>
         <version>1.1</version>