You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2014/12/10 23:37:50 UTC

phoenix git commit: PHOENIX-1393 Add test cases for sub-queries in UPSERT and DELETE statement

Repository: phoenix
Updated Branches:
  refs/heads/master 5722a4d31 -> b093fcfb3


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/b093fcfb
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b093fcfb
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b093fcfb

Branch: refs/heads/master
Commit: b093fcfb3dd5ddf8976f02870e5fdbe993baa853
Parents: 5722a4d
Author: maryannxue <ma...@apache.org>
Authored: Wed Dec 10 17:37:34 2014 -0500
Committer: maryannxue <ma...@apache.org>
Committed: Wed Dec 10 17:37:34 2014 -0500

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


http://git-wip-us.apache.org/repos/asf/phoenix/blob/b093fcfb/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 8e7e6e9..470ba9c 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
@@ -995,6 +995,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);