Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A3C5101AE for ; Wed, 10 Dec 2014 22:51:36 +0000 (UTC) Received: (qmail 42586 invoked by uid 500); 10 Dec 2014 22:51:35 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 42469 invoked by uid 500); 10 Dec 2014 22:51:35 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 42323 invoked by uid 99); 10 Dec 2014 22:51:35 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Dec 2014 22:51:35 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 7A38DA24E8F; Wed, 10 Dec 2014 22:51:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: maryannxue@apache.org To: commits@phoenix.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) 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 Authored: Wed Dec 10 17:44:07 2014 -0500 Committer: maryannxue 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);