private Attribute[] getOnDemandQueryOutputAttributes(OnDemandQuery onDemandQuery, String onDemandQueryString) {
        try {
            OnDemandQueryRuntime onDemandQueryRuntime = onDemandQueryRuntimeMap.get(onDemandQuery);
            if (onDemandQueryRuntime == null) {
                onDemandQueryRuntime = OnDemandQueryParser.parse(onDemandQuery, onDemandQueryString,
                        siddhiAppContext, tableMap, windowMap, aggregationMap);
                onDemandQueryRuntimeMap.put(onDemandQuery, onDemandQueryRuntime);
            }
            return onDemandQueryRuntime.getOnDemandQueryOutputAttributes();
        } catch (RuntimeException e) {
            if (e instanceof SiddhiAppContextException) {
                throw new OnDemandQueryCreationException(((SiddhiAppContextException) e).getMessageWithOutContext(), e,
                        ((SiddhiAppContextException) e).getQueryContextStartIndex(),
                        ((SiddhiAppContextException) e).getQueryContextEndIndex(), null, siddhiAppContext
                        .getSiddhiAppString());
            }
            throw new OnDemandQueryCreationException(e.getMessage(), e);
        }
    }
This method get the onDemandQuery and return the corresponding output and its types.

@param onDemandQuery       this onDemandQuery is processed and get the output attributes.
@param onDemandQueryString this passed to report errors with context if there are any.
@return List of output attributes
modules/siddhi-core/src/main/java/io/siddhi/core/SiddhiAppRuntimeImpl.java