phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maryann...@apache.org
Subject phoenix git commit: PHOENIX-1393 Add test cases for sub-queries in UPSERT and DELETE statement
Date Wed, 10 Dec 2014 22:51:35 GMT
Repository: phoenix
Updated Branches:
  refs/heads/3.0 cabb16f7d -> 042a85fb4


PHOENIX-1393 Add test cases for sub-queries in UPSERT and DELETE statement


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

Branch: refs/heads/3.0
Commit: 042a85fb40ab49b1cdddc78775f3fb3335afe02a
Parents: cabb16f
Author: maryannxue <maryannxue@apache.org>
Authored: Wed Dec 10 17:44:07 2014 -0500
Committer: maryannxue <maryannxue@apache.org>
Committed: Wed Dec 10 17:44:07 2014 -0500

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/SubqueryIT.java  | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/042a85fb/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
index 5a022c6..f20bce2 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SubqueryIT.java
@@ -918,6 +918,36 @@ public class SubqueryIT extends BaseHBaseManagedTimeIT {
     }
 
     @Test
+    public void testSubqueryWithUpsert() throws Exception {
+        String tempTable = "UPSERT_SUBQUERY_TABLE";
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.setAutoCommit(true);
+        try {            
+            conn.createStatement().execute("CREATE TABLE " + tempTable 
+                    + "   (item_id varchar not null primary key, " 
+                    + "    name varchar)");
+            conn.createStatement().execute("UPSERT INTO " + tempTable + "(item_id, name)"
+                    + "   SELECT \"item_id\", name FROM " + JOIN_ITEM_TABLE_FULL_NAME 
+                    + "   WHERE \"item_id\" NOT IN (SELECT \"item_id\" FROM " + JOIN_ORDER_TABLE_FULL_NAME
+ ")");
+            
+            String query = "SELECT name FROM " + tempTable + " ORDER BY item_id";
+            PreparedStatement statement = conn.prepareStatement(query);
+            ResultSet rs = statement.executeQuery();
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "T4");
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "T5");
+            assertTrue (rs.next());
+            assertEquals(rs.getString(1), "INVALID-1");
+
+            assertFalse(rs.next());
+        } finally {
+            conn.close();
+        }
+    }
+
+    @Test
     public void testSubqueryWithDelete() throws Exception {
         String tempTable = "TEMP_SUBQUERY_TABLE";
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);


Mime
View raw message