Java Code Examples for org.apache.phoenix.jdbc.PhoenixPreparedStatement#compileQuery()

The following examples show how to use org.apache.phoenix.jdbc.PhoenixPreparedStatement#compileQuery() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: phoenix   File: HavingCompilerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static Expressions compileStatement(String query, List<Object> binds) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    assertTrue(plan instanceof AggregatePlan);
    Filter filter = plan.getContext().getScan().getFilter();
    assertTrue(filter == null || filter instanceof BooleanExpressionFilter);
    BooleanExpressionFilter boolFilter = (BooleanExpressionFilter)filter;
    AggregatePlan aggPlan = (AggregatePlan)plan;
    return new Expressions(boolFilter == null ? null : boolFilter.getExpression(), aggPlan.getHaving());
}
 
Example 2
Source Project: phoenix   File: QueryCompilerTest.java    License: Apache License 2.0 5 votes vote down vote up
private QueryPlan getQueryPlan(String query, List<Object> binds) throws SQLException {
    Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
    Connection conn = DriverManager.getConnection(getUrl(), props);
    try {
        PhoenixPreparedStatement statement = conn.prepareStatement(query).unwrap(PhoenixPreparedStatement.class);
        for (Object bind : binds) {
            statement.setObject(1, bind);
        }
        return statement.compileQuery(query);
    } finally {
        conn.close();
    }
}
 
Example 3
Source Project: phoenix   File: WhereOptimizerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static StatementContext compileStatement(String query, List<Object> binds, Integer limit) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    assertRoundtrip(query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    assertEquals(limit, plan.getLimit());
    return plan.getContext();
}
 
Example 4
Source Project: phoenix   File: WhereOptimizerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static StatementContext compileStatementTenantSpecific(String tenantId, String query, List<Object> binds) throws Exception {
	PhoenixConnection pconn = getTenantSpecificConnection("tenantId").unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    return  plan.getContext();
}
 
Example 5
private static StatementContext compileStatement(String query, List<Object> binds, Integer limit) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    assertEquals(limit, plan.getLimit());
    return plan.getContext();
}
 
Example 6
Source Project: phoenix   File: HavingCompilerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static Expressions compileStatement(String query, List<Object> binds) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    assertTrue(plan instanceof AggregatePlan);
    Filter filter = plan.getContext().getScan().getFilter();
    assertTrue(filter == null || filter instanceof BooleanExpressionFilter);
    BooleanExpressionFilter boolFilter = (BooleanExpressionFilter)filter;
    AggregatePlan aggPlan = (AggregatePlan)plan;
    return new Expressions(boolFilter == null ? null : boolFilter.getExpression(), aggPlan.getHaving());
}
 
Example 7
Source Project: phoenix   File: WhereOptimizerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static StatementContext compileStatement(String query, List<Object> binds, Integer limit) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    assertRoundtrip(query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    assertEquals(limit, plan.getLimit());
    return plan.getContext();
}
 
Example 8
Source Project: phoenix   File: WhereOptimizerTest.java    License: Apache License 2.0 5 votes vote down vote up
private static StatementContext compileStatementTenantSpecific(String tenantId, String query, List<Object> binds) throws Exception {
	PhoenixConnection pconn = getTenantSpecificConnection("tenantId").unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    return  plan.getContext();
}
 
Example 9
private static QueryPlan compileStatement(String query, List<Object> binds, Integer limit) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    QueryPlan plan = pstmt.compileQuery();
    assertEquals(limit, plan.getLimit());
    return plan;
}
 
Example 10
private static Filter compileStatement(String query) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    QueryPlan plan = pstmt.compileQuery();
    return plan.getContext().getScan().getFilter();
}
 
Example 11
Source Project: phoenix   File: LimitCompilerTest.java    License: Apache License 2.0 4 votes vote down vote up
private static QueryPlan compileStatement(String query, List<Object> binds) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    return pstmt.compileQuery();
}
 
Example 12
private static Filter compileStatement(String query) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    QueryPlan plan = pstmt.compileQuery();
    return plan.getContext().getScan().getFilter();
}
 
Example 13
Source Project: phoenix   File: LimitCompilerTest.java    License: Apache License 2.0 4 votes vote down vote up
private static QueryPlan compileStatement(String query, List<Object> binds) throws SQLException {
    PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class);
    PhoenixPreparedStatement pstmt = new PhoenixPreparedStatement(pconn, query);
    TestUtil.bindParams(pstmt, binds);
    return pstmt.compileQuery();
}