Search in sources :

Example 1 with Property

use of org.teiid.client.plan.PlanNode.Property in project teiid by teiid.

the class TestQueryPlans method testShowPlan.

@Test
public void testShowPlan() throws Exception {
    Statement s = conn.createStatement();
    s.execute("set showplan on");
    ResultSet rs = s.executeQuery("select * from all_tables");
    assertNull(s.unwrap(TeiidStatement.class).getDebugLog());
    rs = s.executeQuery("show plan");
    assertTrue(rs.next());
    assertEquals(rs.getMetaData().getColumnType(1), Types.CLOB);
    assertTrue(rs.getString(1).startsWith("ProjectNode"));
    SQLXML plan = rs.getSQLXML(2);
    assertTrue(plan.getString().startsWith("<?xml"));
    assertNull(rs.getObject("DEBUG_LOG"));
    assertNotNull(rs.getObject("PLAN_TEXT"));
    s.execute("SET showplan debug");
    rs = s.executeQuery("select * from all_tables");
    assertNotNull(s.unwrap(TeiidStatement.class).getDebugLog());
    PlanNode node = s.unwrap(TeiidStatement.class).getPlanDescription();
    Property p = node.getProperty(AnalysisRecord.PROP_DATA_BYTES_SENT);
    assertEquals("20", p.getValues().get(0));
    rs = s.executeQuery("show plan");
    assertTrue(rs.next());
    assertNotNull(rs.getObject("DEBUG_LOG"));
    s.execute("SET showplan off");
    rs = s.executeQuery("select * from all_tables");
    assertNull(s.unwrap(TeiidStatement.class).getPlanDescription());
    assertTrue(rs.next());
}
Also used : SQLXML(java.sql.SQLXML) PlanNode(org.teiid.client.plan.PlanNode) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Property(org.teiid.client.plan.PlanNode.Property) Test(org.junit.Test)

Example 2 with Property

use of org.teiid.client.plan.PlanNode.Property in project teiid by teiid.

the class TestQueryPlans method testShowPlanMultibatch.

@Test
public void testShowPlanMultibatch() throws Exception {
    Statement s = conn.createStatement();
    s.execute("set showplan debug");
    ResultSet rs = s.executeQuery("with x as( select * from sys.columns limit 50) select * from x t1, x t2");
    int count = 0;
    while (rs.next()) {
        count++;
    }
    assertEquals(2500, count);
    rs = s.executeQuery("show plan");
    assertTrue(rs.next());
    assertEquals(rs.getMetaData().getColumnType(2), Types.SQLXML);
    String string = rs.getSQLXML(2).getString();
    PlanNode node = PlanNode.fromXml(string);
    Property p = node.getProperty("Statistics");
    assertTrue(p.getValues().contains("Node Output Rows: 2500"));
}
Also used : PlanNode(org.teiid.client.plan.PlanNode) Statement(java.sql.Statement) ResultSet(java.sql.ResultSet) Property(org.teiid.client.plan.PlanNode.Property) Test(org.junit.Test)

Aggregations

ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 Test (org.junit.Test)2 PlanNode (org.teiid.client.plan.PlanNode)2 Property (org.teiid.client.plan.PlanNode.Property)2 SQLXML (java.sql.SQLXML)1