phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samarth Jain (JIRA)" <j...@apache.org>
Subject [jira] [Created] (PHOENIX-1302) Query against tenant specific view should use index
Date Mon, 29 Sep 2014 19:30:34 GMT
Samarth Jain created PHOENIX-1302:
-------------------------------------

             Summary: Query against tenant specific view should use index
                 Key: PHOENIX-1302
                 URL: https://issues.apache.org/jira/browse/PHOENIX-1302
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 5.0.0, 4.2, 3.2
            Reporter: Samarth Jain


Test that can be added in QueryOptimizerTest.java
{code}
    @Test
    public void testAssertQueryAgainstTenantSpecificViewGoesThroughIndex() throws Exception
{
        Connection conn = DriverManager.getConnection(getUrl(), new Properties());
        
        // create table
        conn.createStatement().execute("create table "
                + "XYZ.ABC"
                + "   (organization_id char(15) not null, \n"
                + "    entity_id char(15) not null,\n"
                + "    a_string_array varchar(100) array[] not null,\n"
                + "    b_string varchar(100),\n"
                + "    a_integer integer,\n"
                + "    a_date date,\n"
                + "    CONSTRAINT pk PRIMARY KEY (organization_id, entity_id, a_string_array)\n"
                + ")" + "MULTI_TENANT=true");

        
        // create index
        conn.createStatement().execute("CREATE INDEX ABC_IDX ON XYZ.ABC (a_integer) INCLUDE
(a_date)");
        
        conn.close();
        
        // switch to a tenant specific connection
        conn = DriverManager.getConnection(getUrl("tenantId"));
        
        // create a tenant specific view
        conn.createStatement().execute("CREATE VIEW ABC_VIEW AS SELECT * FROM XYZ.ABC");
        
        // query against the tenant specific view
        String sql = "SELECT a_date FROM ABC_VIEW where a_integer = ?";
        PreparedStatement stmt = conn.prepareStatement(sql);
        stmt.setInt(1, 1000);
        QueryPlan plan = stmt.unwrap(PhoenixPreparedStatement.class).optimizeQuery();
        assertEquals("Query should use index", PTableType.INDEX, plan.getTableRef().getTable().getType());
    }
{code}

Error:
java.lang.AssertionError: Query should use index expected:<INDEX> but was:<VIEW>






--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message