@Override
    public Object visitStore_query(SiddhiQLParser.Store_queryContext ctx) {

        OutputStream outputStream;
        OnDemandQuery onDemandQuery = OnDemandQuery.query();
        if (ctx.FROM() != null) {
            onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.FIND);
            onDemandQuery.from((InputStore) visit(ctx.store_input()));
            if (ctx.query_section() != null) {
                onDemandQuery = onDemandQuery.select((Selector) visit(ctx.query_section()));
            }
        } else if (ctx.query_section() != null) {
            onDemandQuery.select((Selector) visit(ctx.query_section()));
            if (ctx.UPDATE() != null && ctx.OR() != null) {
                onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.UPDATE_OR_INSERT);
                Source source = (Source) visit(ctx.target());
                if (source.isInnerStream || source.isFaultStream) {
                    throw newSiddhiParserException(ctx, "UPDATE OR INTO INSERT can be only used with Tables!");
                }
                if (ctx.set_clause() != null) {
                    outputStream = new UpdateOrInsertStream(source.streamId,
                            (UpdateSet) visit(ctx.set_clause()), (Expression) visit(ctx.expression()));
                    populateQueryContext(outputStream, ctx);
                } else {
                    outputStream = new UpdateOrInsertStream(source.streamId, (Expression)
                            visit(ctx.expression()));
                    populateQueryContext(outputStream, ctx);
                }
                onDemandQuery.outStream(outputStream);
            } else if (ctx.INSERT() != null) {
                onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.INSERT);
                Source source = (Source) visit(ctx.target());
                if (source.isInnerStream || source.isFaultStream) {
                    throw newSiddhiParserException(ctx, "INSERT can be only used with Tables!");
                }
                outputStream = new InsertIntoStream(source.streamId);
                populateQueryContext(outputStream, ctx);
                onDemandQuery.outStream(outputStream);
            } else if (ctx.store_query_output() != null) {
                outputStream = (OutputStream) visit(ctx.store_query_output());
                if (outputStream instanceof DeleteStream) {
                    onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.DELETE);
                } else if (outputStream instanceof UpdateStream) {
                    onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.UPDATE);
                }
                onDemandQuery.outStream(outputStream);
            }
        } else if (ctx.store_query_output() != null) {
            outputStream = (OutputStream) visit(ctx.store_query_output());
            if (outputStream instanceof DeleteStream) {
                onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.DELETE);
            } else if (outputStream instanceof UpdateStream) {
                onDemandQuery.setType(OnDemandQuery.OnDemandQueryType.UPDATE);
            }
            onDemandQuery.outStream(outputStream);
        }
        populateQueryContext(onDemandQuery, ctx);
        return onDemandQuery;
    }
{@inheritDoc}
<p>The default implementation returns the result of calling
{@link #visitChildren} on {@code ctx}.</p>

@param ctx
modules/siddhi-query-compiler/src/main/java/io/siddhi/query/compiler/internal/SiddhiQLBaseVisitorImpl.java