Search in sources :

Example 31 with PlanNode

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

the class ProcessorPlan method getDescriptionProperties.

public PlanNode getDescriptionProperties() {
    PlanNode props = new PlanNode(this.getClass().getSimpleName());
    props.addProperty(PROP_OUTPUT_COLS, AnalysisRecord.getOutputColumnProperties(getOutputElements()));
    return props;
}
Also used : PlanNode(org.teiid.client.plan.PlanNode)

Example 32 with PlanNode

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

the class AssignmentInstruction method getDescriptionProperties.

public PlanNode getDescriptionProperties() {
    // $NON-NLS-1$
    PlanNode props = new PlanNode("ASSIGNMENT");
    props.addProperty(PROP_VARIABLE, this.variable.toString());
    if (this.expression != null) {
        AnalysisRecord.addLanaguageObjects(props, PROP_EXPRESSION, Arrays.asList(this.expression));
    }
    return props;
}
Also used : PlanNode(org.teiid.client.plan.PlanNode)

Example 33 with PlanNode

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

the class TestResultsMessage method example.

public static ResultsMessage example() {
    ResultsMessage message = new ResultsMessage();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    message.setColumnNames(new String[] { "A", "B", "C", "D" });
    message.setDataTypes(new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_INTEGER });
    message.setFinalRow(200);
    message.setFirstRow(1);
    message.setLastRow(100);
    List parameters = new ArrayList();
    parameters.add(new ParameterInfo(ParameterInfo.IN, 0));
    parameters.add(new ParameterInfo(ParameterInfo.RESULT_SET, 5));
    message.setParameters(parameters);
    PlanNode planDescs = new PlanNode("test");
    // $NON-NLS-1$ //$NON-NLS-2$
    planDescs.addProperty("key1", "val1");
    // $NON-NLS-1$ //$NON-NLS-2$
    planDescs.addProperty("key2", "val2");
    // $NON-NLS-1$ //$NON-NLS-2$
    planDescs.addProperty("key3", "val3");
    // $NON-NLS-1$ //$NON-NLS-2$
    planDescs.addProperty("key4", "val4");
    message.setPlanDescription(planDescs);
    List results = new ArrayList();
    // $NON-NLS-1$
    results.add(new BigInteger("100"));
    // $NON-NLS-1$
    results.add(new BigInteger("200"));
    // $NON-NLS-1$
    results.add(new BigInteger("300"));
    // $NON-NLS-1$
    results.add(new BigInteger("400"));
    message.setResults(new List[] { results });
    List warnings = new ArrayList();
    // $NON-NLS-1$
    warnings.add(new Exception("warning1"));
    // $NON-NLS-1$
    warnings.add(new Exception("warning2"));
    message.setWarnings(warnings);
    return message;
}
Also used : PlanNode(org.teiid.client.plan.PlanNode) ResultsMessage(org.teiid.client.ResultsMessage) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) List(java.util.List) ArrayList(java.util.ArrayList) ParameterInfo(org.teiid.client.metadata.ParameterInfo)

Example 34 with PlanNode

use of org.teiid.client.plan.PlanNode 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 35 with PlanNode

use of org.teiid.client.plan.PlanNode 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

PlanNode (org.teiid.client.plan.PlanNode)35 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 SymbolMap (org.teiid.query.sql.util.SymbolMap)3 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 Property (org.teiid.client.plan.PlanNode.Property)2 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)2 BigInteger (java.math.BigInteger)1 SQLXML (java.sql.SQLXML)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 RequestMessage (org.teiid.client.RequestMessage)1 ResultsMessage (org.teiid.client.ResultsMessage)1 ParameterInfo (org.teiid.client.metadata.ParameterInfo)1 Annotation (org.teiid.client.plan.Annotation)1 SQLXMLImpl (org.teiid.core.types.SQLXMLImpl)1 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)1