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 CA672200D33 for ; Wed, 4 Oct 2017 00:09:46 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C8E7A1609DE; Tue, 3 Oct 2017 22:09:46 +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 18E06160BD5 for ; Wed, 4 Oct 2017 00:09:45 +0200 (CEST) Received: (qmail 16689 invoked by uid 500); 3 Oct 2017 22:09:45 -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 16680 invoked by uid 99); 3 Oct 2017 22:09:45 -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; Tue, 03 Oct 2017 22:09:45 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0E3ABF5763; Tue, 3 Oct 2017 22:09:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jamestaylor@apache.org To: commits@phoenix.apache.org Date: Tue, 03 Oct 2017 22:09:46 -0000 Message-Id: <58839405863c4fbab61d21a52c9f880e@git.apache.org> In-Reply-To: <2baa75d9a55d4478b80796ed58fdbb3b@git.apache.org> References: <2baa75d9a55d4478b80796ed58fdbb3b@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] phoenix git commit: PHOENIX-4274 Test case for Hint query for index on view does not use include archived-at: Tue, 03 Oct 2017 22:09:47 -0000 PHOENIX-4274 Test case for Hint query for index on view does not use include Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e40bbfff Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e40bbfff Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e40bbfff Branch: refs/heads/4.x-HBase-1.1 Commit: e40bbfff1150e56e1ecb7cd22c49cee298496c2b Parents: 347304e Author: James Taylor Authored: Tue Oct 3 15:04:30 2017 -0700 Committer: James Taylor Committed: Tue Oct 3 15:08:44 2017 -0700 ---------------------------------------------------------------------- .../phoenix/end2end/index/ViewIndexIT.java | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/e40bbfff/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java index 8ea6c27..53bb550 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/ViewIndexIT.java @@ -44,7 +44,6 @@ import org.apache.phoenix.jdbc.PhoenixStatement; import org.apache.phoenix.query.KeyRange; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.schema.PNameFactory; -import org.apache.phoenix.schema.PTableType; import org.apache.phoenix.schema.TableNotFoundException; import org.apache.phoenix.util.MetaDataUtil; import org.apache.phoenix.util.PhoenixRuntime; @@ -52,6 +51,7 @@ import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.SchemaUtil; import org.apache.phoenix.util.TestUtil; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -413,4 +413,35 @@ public class ViewIndexIT extends ParallelStatsDisabledIT { conn.close(); } } + + @Test + public void testHintForIndexOnViewWithInclude() throws Exception { + testHintForIndexOnView(true); + } + + @Ignore("PHOENIX-4274 Hint query for index on view does not use include") + @Test + public void testHintForIndexOnViewWithoutInclude() throws Exception { + testHintForIndexOnView(false); + } + + private void testHintForIndexOnView(boolean includeColumns) throws Exception { + Properties props = new Properties(); + Connection conn1 = DriverManager.getConnection(getUrl(), props); + conn1.setAutoCommit(true); + String tableName=generateUniqueName(); + String viewName=generateUniqueName(); + String indexName=generateUniqueName(); + conn1.createStatement().execute( + "CREATE TABLE "+tableName+" (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) UPDATE_CACHE_FREQUENCY=1000000"); + conn1.createStatement().execute("upsert into "+tableName+" values ('row1', 'value1', 'key1')"); + conn1.createStatement().execute( + "CREATE VIEW "+viewName+" (v3 VARCHAR, v4 VARCHAR) AS SELECT * FROM "+tableName+" WHERE v1 = 'value1'"); + conn1.createStatement().execute("CREATE INDEX " + indexName + " ON " + viewName + "(v3)" + (includeColumns ? " INCLUDE(v4)" : "")); + PhoenixStatement stmt = conn1.createStatement().unwrap(PhoenixStatement.class); + ResultSet rs = stmt.executeQuery("SELECT /*+ INDEX(" + viewName + " " + indexName + ") */ v1 FROM " + viewName + " WHERE v3 = 'foo' ORDER BY v4"); + assertFalse(rs.next()); + assertEquals(indexName, stmt.getQueryPlan().getContext().getCurrentTable().getTable().getName().getString()); + } + }