private MetaStateEvent constructExpression(MetaStreamEvent metaStreamEvent,
                                               SiddhiQueryContext siddhiQueryContext) {
        Expression expression = SiddhiCompiler.parseExpression(expressionString);
        MetaStreamEvent metaStreamEventFirst = new MetaStreamEventWrapper(metaStreamEvent);
        metaStreamEventFirst.setInputReferenceId("first");
        MetaStreamEvent metaStreamEventLast = new MetaStreamEventWrapper(metaStreamEvent);
        metaStreamEventLast.setInputReferenceId("last");
        MetaStateEvent metaStateEvent = new MetaStateEvent(
                new MetaStreamEvent[]{metaStreamEvent, metaStreamEventFirst, metaStreamEventLast});
        variableExpressionExecutors = new ArrayList<>();
        SiddhiQueryContext exprQueryContext = new SiddhiOnDemandQueryContext(
                siddhiQueryContext.getSiddhiAppContext(), siddhiQueryContext.getName(),
                expressionString);
        expressionExecutor = ExpressionParser.parseExpression(expression, metaStateEvent,
                0, new HashMap<>(), variableExpressionExecutors, false,
                0, ProcessingMode.SLIDE, true, exprQueryContext);
        if (expressionExecutor.getReturnType() != Attribute.Type.BOOL) {
            throw new SiddhiAppRuntimeException("Expression ('" + expressionString + "') does not return Bool");
        }
        return metaStateEvent;
    }
Implementation of {@link WindowProcessor} which represent a Window operating based on a expression.
modules/siddhi-core/src/main/java/io/siddhi/core/query/processor/stream/window/ExpressionWindowProcessor.java