use of org.apache.phoenix.jdbc.PhoenixStatement in project phoenix by apache.
the class QueryOptimizerTest method testRVCAllColsForTableWithSecondaryIndexBasic.
@Test
public void testRVCAllColsForTableWithSecondaryIndexBasic() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
conn.createStatement().execute("CREATE TABLE T (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
conn.createStatement().execute("CREATE INDEX IDX ON T(v1, v2)");
PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
String query = "select * from t where (k, v1, v2) <= ('3', '1', '2')";
QueryPlan plan = stmt.optimizeQuery(query);
assertEquals("T", plan.getTableRef().getTable().getTableName().getString());
}
use of org.apache.phoenix.jdbc.PhoenixStatement in project phoenix by apache.
the class QueryOptimizerTest method testOrderByDroppedCompositeKey.
@Test
public void testOrderByDroppedCompositeKey() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
conn.createStatement().execute("CREATE TABLE foo (j INTEGER NOT NULL, k BIGINT NOT NULL, v VARCHAR CONSTRAINT pk PRIMARY KEY (j,k)) IMMUTABLE_ROWS=true");
PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
QueryPlan plan = stmt.optimizeQuery("SELECT * FROM foo ORDER BY j,k");
assertEquals(OrderBy.FWD_ROW_KEY_ORDER_BY, plan.getOrderBy());
}
use of org.apache.phoenix.jdbc.PhoenixStatement in project phoenix by apache.
the class QueryOptimizerTest method testOrderByOptimizedOut.
@Test
public void testOrderByOptimizedOut() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
conn.createStatement().execute("CREATE TABLE foo (k VARCHAR NOT NULL PRIMARY KEY, v VARCHAR) IMMUTABLE_ROWS=true");
PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
QueryPlan plan = stmt.optimizeQuery("SELECT * FROM foo ORDER BY k");
assertEquals(OrderBy.FWD_ROW_KEY_ORDER_BY, plan.getOrderBy());
}
use of org.apache.phoenix.jdbc.PhoenixStatement in project phoenix by apache.
the class QueryOptimizerTest method testChooseIndexFromOrderByAsc.
@Test
public void testChooseIndexFromOrderByAsc() throws Exception {
Connection conn = DriverManager.getConnection(getUrl());
conn.createStatement().execute("CREATE TABLE t (k INTEGER NOT NULL PRIMARY KEY DESC, v1 VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
conn.createStatement().execute("CREATE INDEX idx ON t(v1, k)");
PhoenixStatement stmt = conn.createStatement().unwrap(PhoenixStatement.class);
QueryPlan plan = stmt.optimizeQuery("SELECT k FROM t WHERE k > 30 ORDER BY v1, k LIMIT 5");
assertEquals("IDX", plan.getTableRef().getTable().getTableName().getString());
}
Aggregations