Search in sources :

Example 16 with PlanNode

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

the class RequestWorkItem method setAnalysisRecords.

private void setAnalysisRecords(ResultsMessage response) {
    if (analysisRecord != null) {
        if (requestMsg.getShowPlan() != ShowPlan.OFF) {
            if (processor != null) {
                PlanNode node = processor.getProcessorPlan().getDescriptionProperties();
                node.addProperty(AnalysisRecord.PROP_DATA_BYTES_SENT, String.valueOf(dataBytes.get()));
                if (planningEnd != 0) {
                    node.addProperty(AnalysisRecord.PROP_PLANNING_TIME, String.valueOf(planningEnd - planningStart));
                }
                response.setPlanDescription(node);
            }
            if (analysisRecord.getAnnotations() != null && !analysisRecord.getAnnotations().isEmpty()) {
                response.setAnnotations(analysisRecord.getAnnotations());
                analysisRecord.getAnnotations().clear();
            }
        }
        if (requestMsg.getShowPlan() == ShowPlan.DEBUG) {
            response.setDebugLog(analysisRecord.getDebugLog());
            analysisRecord.stopDebugLog();
        }
    }
}
Also used : PlanNode(org.teiid.client.plan.PlanNode)

Example 17 with PlanNode

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

the class DQPCore method logMMCommand.

void logMMCommand(RequestWorkItem workItem, Event status, Long rowCount, Long cpuTime) {
    if ((status != Event.PLAN && !LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.INFO)) || (status == Event.PLAN && !LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.TRACE))) {
        return;
    }
    RequestMessage msg = workItem.requestMsg;
    DQPWorkContext workContext = DQPWorkContext.getWorkContext();
    RequestID rID = workItem.requestID;
    String txnID = null;
    TransactionContext tc = workItem.getTransactionContext();
    if (tc != null && tc.getTransactionType() != Scope.NONE) {
        txnID = tc.getTransactionId();
    }
    String appName = workContext.getAppName();
    // Log to request log
    CommandLogMessage message = null;
    if (status == Event.NEW) {
        message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getSessionId(), appName, workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), msg.getCommandString(), cpuTime);
    } else {
        QueryProcessor qp = workItem.getProcessor();
        PlanNode plan = null;
        if (LogManager.isMessageToBeRecorded(LogConstants.CTX_COMMANDLOGGING, MessageLevel.TRACE) && qp != null) {
            plan = qp.getProcessorPlan().getDescriptionProperties();
        }
        message = new CommandLogMessage(System.currentTimeMillis(), rID.toString(), txnID, workContext.getSessionId(), workContext.getUserName(), workContext.getVdbName(), workContext.getVdbVersion(), rowCount, status, plan);
    }
    LogManager.log(status == Event.PLAN ? MessageLevel.TRACE : MessageLevel.INFO, LogConstants.CTX_COMMANDLOGGING, message);
}
Also used : PlanNode(org.teiid.client.plan.PlanNode) RequestID(org.teiid.dqp.message.RequestID) TransactionContext(org.teiid.dqp.service.TransactionContext) AtomicRequestMessage(org.teiid.dqp.message.AtomicRequestMessage) RequestMessage(org.teiid.client.RequestMessage) CommandLogMessage(org.teiid.logging.CommandLogMessage) QueryProcessor(org.teiid.query.processor.QueryProcessor)

Example 18 with PlanNode

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

the class TestGroupingNode method testDescriptionProperties.

@Test
public void testDescriptionProperties() {
    GroupingNode node = getExampleGroupingNode();
    SymbolMap outputMapping = new SymbolMap();
    outputMapping.addMapping(new ElementSymbol("agg0"), new AggregateSymbol("count", false, null));
    node.setOutputMapping(outputMapping);
    PlanNode pn = node.getDescriptionProperties();
    assertTrue(pn.toString().contains("agg0=count(*)"));
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) AggregateSymbol(org.teiid.query.sql.symbol.AggregateSymbol) PlanNode(org.teiid.client.plan.PlanNode) SymbolMap(org.teiid.query.sql.util.SymbolMap) Test(org.junit.Test)

Example 19 with PlanNode

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

the class StatementImpl method executeShow.

ResultsFuture<Boolean> executeShow(Matcher match) throws SQLException {
    String show = match.group(1);
    show = unescapeId(show);
    if (show.equalsIgnoreCase("PLAN")) {
        // $NON-NLS-1$
        List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
        PlanNode plan = driverConnection.getCurrentPlanDescription();
        String connDebugLog = driverConnection.getDebugLog();
        if (plan != null || connDebugLog != null) {
            ArrayList<Object> row = new ArrayList<Object>(3);
            if (plan != null) {
                row.add(DataTypeTransformer.getClob(plan.toString()));
                row.add(new SQLXMLImpl(plan.toXml()));
            } else {
                row.add(null);
                row.add(null);
            }
            row.add(DataTypeTransformer.getClob(connDebugLog));
            records.add(row);
        }
        createResultSet(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        records, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        new String[] { "PLAN_TEXT", "PLAN_XML", "DEBUG_LOG" }, new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.XML, DataTypeManager.DefaultDataTypes.CLOB });
        return booleanFuture(true);
    }
    if (show.equalsIgnoreCase("ANNOTATIONS")) {
        // $NON-NLS-1$
        List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
        Collection<Annotation> annos = driverConnection.getAnnotations();
        for (Annotation annotation : annos) {
            ArrayList<Object> row = new ArrayList<Object>(4);
            row.add(annotation.getCategory());
            row.add(annotation.getPriority().name());
            row.add(annotation.getAnnotation());
            row.add(annotation.getResolution());
            records.add(row);
        }
        createResultSet(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        records, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        new String[] { "CATEGORY", "PRIORITY", "ANNOTATION", "RESOLUTION" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
        return booleanFuture(true);
    }
    if (show.equalsIgnoreCase("ALL")) {
        // $NON-NLS-1$
        List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
        for (String key : driverConnection.getExecutionProperties().stringPropertyNames()) {
            ArrayList<Object> row = new ArrayList<Object>(4);
            row.add(key);
            row.add(driverConnection.getExecutionProperties().get(key));
            records.add(row);
        }
        createResultSet(// $NON-NLS-1$ //$NON-NLS-2$
        records, // $NON-NLS-1$ //$NON-NLS-2$
        new String[] { "NAME", "VALUE" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
        return booleanFuture(true);
    }
    if (show.equalsIgnoreCase("transaction isolation level")) {
        // $NON-NLS-1$
        List<ArrayList<Object>> records = new ArrayList<ArrayList<Object>>(1);
        ArrayList<Object> row = new ArrayList<Object>(1);
        switch(driverConnection.getTransactionIsolation()) {
            case Connection.TRANSACTION_READ_COMMITTED:
                // $NON-NLS-1$
                row.add("READ COMMITTED");
                break;
            case Connection.TRANSACTION_READ_UNCOMMITTED:
                // $NON-NLS-1$
                row.add("READ UNCOMMITTED");
                break;
            case Connection.TRANSACTION_REPEATABLE_READ:
                // $NON-NLS-1$
                row.add("REPEATABLE READ");
                break;
            case Connection.TRANSACTION_SERIALIZABLE:
                // $NON-NLS-1$
                row.add("SERIALIZABLE");
                break;
            default:
                // $NON-NLS-1$
                row.add("UNKNOWN");
        }
        records.add(row);
        createResultSet(// $NON-NLS-1$
        records, // $NON-NLS-1$
        new String[] { "TRANSACTION ISOLATION" }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
        return booleanFuture(true);
    }
    List<List<String>> records = Collections.singletonList(Collections.singletonList(driverConnection.getExecutionProperty(show)));
    createResultSet(records, new String[] { show }, new String[] { DataTypeManager.DefaultDataTypes.STRING });
    return booleanFuture(true);
}
Also used : SQLXMLImpl(org.teiid.core.types.SQLXMLImpl) PlanNode(org.teiid.client.plan.PlanNode) Annotation(org.teiid.client.plan.Annotation)

Example 20 with PlanNode

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

the class IfInstruction method getDescriptionProperties.

public PlanNode getDescriptionProperties() {
    // $NON-NLS-1$
    PlanNode props = new PlanNode("IF");
    props.addProperty(PROP_CRITERIA, this.condition.toString());
    props.addProperty(PROP_THEN, this.ifProgram.getDescriptionProperties());
    if (elseProgram != null) {
        props.addProperty(PROP_ELSE, this.elseProgram.getDescriptionProperties());
    }
    return props;
}
Also used : PlanNode(org.teiid.client.plan.PlanNode)

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