private static List<AttributeProcessor> getAttributeProcessors(Selector selector, String id,
                                                                   MetaComplexEvent metaComplexEvent,
                                                                   Map<String, Table> tableMap,
                                                                   List<VariableExpressionExecutor>
                                                                           variableExpressionExecutors,
                                                                   OutputStream outputStream,
                                                                   int metaPosition,
                                                                   ProcessingMode processingMode,
                                                                   boolean outputExpectsExpiredEvents,
                                                                   boolean groupBy,
                                                                   SiddhiQueryContext siddhiQueryContext) {

        List<AttributeProcessor> attributeProcessorList = new ArrayList<>();
        StreamDefinition outputDefinition = StreamDefinition.id(id);
        outputDefinition.setQueryContextStartIndex(outputStream.getQueryContextStartIndex());
        outputDefinition.setQueryContextEndIndex(outputStream.getQueryContextEndIndex());
        List<OutputAttribute> outputAttributes = selector.getSelectionList();
        if (selector.getSelectionList().size() == 0) {
            if (metaComplexEvent instanceof MetaStreamEvent) {

                List<Attribute> attributeList = ((MetaStreamEvent) metaComplexEvent).getLastInputDefinition()
                        .getAttributeList();
                for (Attribute attribute : attributeList) {
                    Variable variable = new Variable(attribute.getName());
                    variable.setQueryContextStartIndex(selector.getQueryContextStartIndex());
                    variable.setQueryContextEndIndex(selector.getQueryContextEndIndex());
                    OutputAttribute outputAttribute = new OutputAttribute(variable);
                    outputAttribute.setQueryContextStartIndex(selector.getQueryContextStartIndex());
                    outputAttribute.setQueryContextEndIndex(selector.getQueryContextEndIndex());
                    outputAttributes.add(outputAttribute);
                }
            } else {
                int position = 0;
                for (MetaStreamEvent metaStreamEvent : ((MetaStateEvent) metaComplexEvent).getMetaStreamEvents()) {
                    if (metaPosition == SiddhiConstants.UNKNOWN_STATE || metaPosition == position) {
                        List<Attribute> attributeList = metaStreamEvent.getLastInputDefinition().getAttributeList();
                        for (Attribute attribute : attributeList) {
                            Variable variable = new Variable(attribute.getName());
                            variable.setQueryContextStartIndex(selector.getQueryContextStartIndex());
                            variable.setQueryContextEndIndex(selector.getQueryContextEndIndex());
                            OutputAttribute outputAttribute = new OutputAttribute(variable);
                            outputAttribute.setQueryContextStartIndex(selector.getQueryContextStartIndex());
                            outputAttribute.setQueryContextEndIndex(selector.getQueryContextEndIndex());
                            if (!outputAttributes.contains(outputAttribute)) {
                                outputAttributes.add(outputAttribute);
                            } else {
                                List<AbstractDefinition> definitions = new ArrayList<>();
                                for (MetaStreamEvent aMetaStreamEvent : ((MetaStateEvent) metaComplexEvent)
                                        .getMetaStreamEvents()) {
                                    definitions.add(aMetaStreamEvent.getLastInputDefinition());
                                }
                                throw new DuplicateAttributeException("Duplicate attribute exist in streams " +
                                        definitions, outputStream.getQueryContextStartIndex(),
                                        outputStream.getQueryContextEndIndex());
                            }
                        }
                    }
                    ++position;
                }
            }
        }

        int i = 0;
        for (OutputAttribute outputAttribute : outputAttributes) {

            ExpressionExecutor expressionExecutor = ExpressionParser.parseExpression(outputAttribute.getExpression(),
                    metaComplexEvent, SiddhiConstants.UNKNOWN_STATE, tableMap, variableExpressionExecutors,
                    groupBy, 0, processingMode,
                    outputExpectsExpiredEvents, siddhiQueryContext);
            if (expressionExecutor instanceof VariableExpressionExecutor) {   //for variables we will directly put
                // value at conversion stage
                VariableExpressionExecutor executor = ((VariableExpressionExecutor) expressionExecutor);
                if (metaComplexEvent instanceof MetaStateEvent) {
                    ((MetaStateEvent) metaComplexEvent).addOutputDataAllowingDuplicate(new MetaStateEventAttribute(executor
                            .getAttribute(), executor.getPosition()));
                } else {
                    ((MetaStreamEvent) metaComplexEvent).addOutputDataAllowingDuplicate(executor.getAttribute());
                }
                outputDefinition.attribute(outputAttribute.getRename(), ((VariableExpressionExecutor)
                        expressionExecutor).getAttribute().getType());
            } else {
                //To maintain output variable positions
                if (metaComplexEvent instanceof MetaStateEvent) {
                    ((MetaStateEvent) metaComplexEvent).addOutputDataAllowingDuplicate(null);
                } else {
                    ((MetaStreamEvent) metaComplexEvent).addOutputDataAllowingDuplicate(null);
                }
                AttributeProcessor attributeProcessor = new AttributeProcessor(expressionExecutor);
                attributeProcessor.setOutputPosition(i);
                attributeProcessorList.add(attributeProcessor);
                outputDefinition.attribute(outputAttribute.getRename(), attributeProcessor.getOutputType());
            }
            i++;
        }
        metaComplexEvent.setOutputDefinition(outputDefinition);
        return attributeProcessorList;
    }
Method to construct AttributeProcessor list for the selector.

@param selector                    Selector
@param id                          stream id
@param metaComplexEvent            meta ComplexEvent
@param tableMap                    Table Map
@param variableExpressionExecutors list of VariableExpressionExecutors
@param outputStream                output stream
@param processingMode              processing mode of the query
@param outputExpectsExpiredEvents  is expired events sent as output
@param groupBy                     is Attributes groupBy
@param siddhiQueryContext          current siddhi query context  @return list of AttributeProcessors
modules/siddhi-core/src/main/java/io/siddhi/core/util/parser/SelectorParser.java