Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 77166200C73 for ; Wed, 10 May 2017 20:04:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 75EC0160B99; Wed, 10 May 2017 18:04:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F41B5160B9C for ; Wed, 10 May 2017 20:04:05 +0200 (CEST) Received: (qmail 32367 invoked by uid 500); 10 May 2017 18:04:05 -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 30518 invoked by uid 99); 10 May 2017 18:04:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 May 2017 18:04:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E8B0FEEE1A; Wed, 10 May 2017 18:04:00 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tdsilva@apache.org To: commits@phoenix.apache.org Date: Wed, 10 May 2017 18:04:33 -0000 Message-Id: In-Reply-To: <0bd8781639664f1ca1a80e5954b66740@git.apache.org> References: <0bd8781639664f1ca1a80e5954b66740@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [34/46] phoenix git commit: PHOENIX-3800 NPE when doing UPSERT SELECT into salted tables archived-at: Wed, 10 May 2017 18:04:07 -0000 PHOENIX-3800 NPE when doing UPSERT SELECT into salted tables Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f51c0db9 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f51c0db9 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f51c0db9 Branch: refs/heads/omid Commit: f51c0db9f2d2ee261e602a114d47dd63353bbba8 Parents: 5b09901 Author: Ankit Singhal Authored: Fri May 5 11:38:44 2017 +0530 Committer: Ankit Singhal Committed: Fri May 5 11:38:44 2017 +0530 ---------------------------------------------------------------------- .../apache/phoenix/end2end/UpsertSelectIT.java | 21 +++++++++++++++----- .../apache/phoenix/compile/UpsertCompiler.java | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/f51c0db9/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java index 0a20d47..1c04acb 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java @@ -78,20 +78,31 @@ public class UpsertSelectIT extends BaseClientManagedTimeIT { @Test public void testUpsertSelectWithNoIndex() throws Exception { - testUpsertSelect(false); + testUpsertSelect(false, false); } @Test public void testUpsertSelecWithIndex() throws Exception { - testUpsertSelect(true); + testUpsertSelect(true, false); } - private void testUpsertSelect(boolean createIndex) throws Exception { + @Test + public void testUpsertSelecWithIndexWithSalt() throws Exception { + testUpsertSelect(true, true); + } + + @Test + public void testUpsertSelecWithNoIndexWithSalt() throws Exception { + testUpsertSelect(false, true); + } + + private void testUpsertSelect(boolean createIndex, boolean saltTable) throws Exception { long ts = nextTimestamp(); String tenantId = getOrganizationId(); - initATableValues(ATABLE_NAME, tenantId, getDefaultSplits(tenantId), null, ts-1, getUrl(), null); + byte[][] splits = getDefaultSplits(tenantId); + initATableValues(ATABLE_NAME, tenantId, saltTable ? null : splits, null, ts-1, getUrl(), saltTable ? "salt_buckets = 2" : null); - ensureTableCreated(getUrl(), CUSTOM_ENTITY_DATA_FULL_NAME, CUSTOM_ENTITY_DATA_FULL_NAME, ts-1); + ensureTableCreated(getUrl(), CUSTOM_ENTITY_DATA_FULL_NAME, CUSTOM_ENTITY_DATA_FULL_NAME, null, ts-1, saltTable ? "salt_buckets = 2" : null); String indexName = "IDX1"; if (createIndex) { Properties props = new Properties(); http://git-wip-us.apache.org/repos/asf/phoenix/blob/f51c0db9/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java index 2304d83..5559ad7 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java @@ -677,7 +677,7 @@ public class UpsertCompiler { for (int i = 0 ; i < projectedExpressions.size(); i++) { // Must make new column if position has changed PColumn column = allColumns.get(allColumnsIndexes[i]); - projectedColumns.add(column.getPosition() == i + posOff ? column : new PColumnImpl(column, i)); + projectedColumns.add(column.getPosition() == i + posOff ? column : new PColumnImpl(column, i + posOff)); } // Build table from projectedColumns // Hack to add default column family to be used on server in case no value column is projected.