private static OnDemandQueryRuntime constructRegularOnDemandQueryRuntime(Table table, OnDemandQuery onDemandQuery,
                                                                             Map<String, Table> tableMap,
                                                                             Map<String, Window> windowMap,
                                                                             int metaPosition, Expression onCondition,
                                                                             MetaStreamEvent metaStreamEvent,
                                                                             List<VariableExpressionExecutor>
                                                                                     variableExpressionExecutors,
                                                                             LockWrapper lockWrapper,
                                                                             SiddhiQueryContext siddhiQueryContext) {
        MatchingMetaInfoHolder matchingMetaInfoHolder;
        AbstractDefinition inputDefinition;
        QuerySelector querySelector;

        switch (onDemandQuery.getType()) {
            case FIND:
                initMetaStreamEvent(metaStreamEvent, table.getTableDefinition());
                matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent,
                        table.getTableDefinition());
                CompiledCondition compiledCondition = table.compileCondition(onCondition, matchingMetaInfoHolder,
                        variableExpressionExecutors, tableMap, siddhiQueryContext);

                FindOnDemandQueryRuntime findOnDemandQueryRuntime = new FindOnDemandQueryRuntime(table, compiledCondition,
                        siddhiQueryContext.getName(), metaStreamEvent);
                populateFindOnDemandQueryRuntime(findOnDemandQueryRuntime, matchingMetaInfoHolder,
                        onDemandQuery.getSelector(), variableExpressionExecutors,
                        tableMap, windowMap, metaPosition, !onDemandQuery.getSelector().getGroupByList().isEmpty(),
                        lockWrapper, siddhiQueryContext);
                return findOnDemandQueryRuntime;
            case INSERT:
                initMetaStreamEvent(metaStreamEvent, getInputDefinition(onDemandQuery, table));
                matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent,
                        table.getTableDefinition());
                querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors,
                        tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);

                InsertOnDemandQueryRuntime insertOnDemandQueryRuntime =
                        new InsertOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
                insertOnDemandQueryRuntime.setStateEventFactory(
                        new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
                insertOnDemandQueryRuntime.setSelector(querySelector);
                insertOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent()
                        .getOutputStreamDefinition().getAttributeList());
                return insertOnDemandQueryRuntime;
            case DELETE:
                inputDefinition = getInputDefinition(onDemandQuery, table);
                initMetaStreamEvent(metaStreamEvent, inputDefinition);
                matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent,
                        inputDefinition, table.getTableDefinition());
                querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors,
                        tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);

                DeleteOnDemandQueryRuntime deleteOnDemandQueryRuntime =
                        new DeleteOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
                deleteOnDemandQueryRuntime.setStateEventFactory(
                        new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
                deleteOnDemandQueryRuntime.setSelector(querySelector);
                deleteOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent()
                        .getOutputStreamDefinition().getAttributeList());
                return deleteOnDemandQueryRuntime;
            case UPDATE:
                inputDefinition = getInputDefinition(onDemandQuery, table);
                initMetaStreamEvent(metaStreamEvent, inputDefinition);
                matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, inputDefinition,
                        table.getTableDefinition());
                querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors,
                        tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);

                UpdateOnDemandQueryRuntime updateOnDemandQueryRuntime =
                        new UpdateOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
                updateOnDemandQueryRuntime.setStateEventFactory(
                        new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
                updateOnDemandQueryRuntime.setSelector(querySelector);
                updateOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent()
                        .getOutputStreamDefinition().getAttributeList());
                return updateOnDemandQueryRuntime;
            case UPDATE_OR_INSERT:
                inputDefinition = getInputDefinition(onDemandQuery, table);
                initMetaStreamEvent(metaStreamEvent, inputDefinition);
                matchingMetaInfoHolder = generateMatchingMetaInfoHolder(metaStreamEvent, inputDefinition,
                        table.getTableDefinition());
                querySelector = getQuerySelector(matchingMetaInfoHolder, variableExpressionExecutors,
                        tableMap, windowMap, metaPosition, onDemandQuery, lockWrapper, siddhiQueryContext);

                UpdateOrInsertOnDemandQueryRuntime updateOrInsertIntoOnDemandQueryRuntime =
                        new UpdateOrInsertOnDemandQueryRuntime(siddhiQueryContext.getName(), metaStreamEvent);
                updateOrInsertIntoOnDemandQueryRuntime.setStateEventFactory(
                        new StateEventFactory(matchingMetaInfoHolder.getMetaStateEvent()));
                updateOrInsertIntoOnDemandQueryRuntime.setSelector(querySelector);
                updateOrInsertIntoOnDemandQueryRuntime.setOutputAttributes(matchingMetaInfoHolder.getMetaStateEvent()
                        .getOutputStreamDefinition().getAttributeList());
                return updateOrInsertIntoOnDemandQueryRuntime;
            default:
                return null;
        }
    }
Parse a onDemandQuery and return corresponding OnDemandQueryRuntime.

@param onDemandQuery       onDemandQuery to be parsed.
@param siddhiQueryContext associated Siddhi query context.
@param tableMap         keyvalue containing tables.
@param windowMap        keyvalue containing windows.
@param aggregationMap   keyvalue containing aggregation runtimes.
@return OnDemandQueryRuntime
modules/siddhi-core/src/main/java/io/siddhi/core/util/parser/OnDemandQueryParser.java