Search in sources :

Example 6 with OutputAttribute

use of org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitQuery_section.

/**
 * {@inheritDoc}
 * <p>The default implementation returns the result of calling
 * {@link #visitChildren} on {@code ctx}.</p>
 *
 * @param ctx
 */
@Override
public Selector visitQuery_section(@NotNull SiddhiQLParser.Query_sectionContext ctx) {
    // query_section
    // :(SELECT ('*'| (output_attribute (',' output_attribute)* ))) group_by? having?
    // ;
    Selector selector = new Selector();
    List<OutputAttribute> attributeList = new ArrayList<OutputAttribute>(ctx.output_attribute().size());
    for (SiddhiQLParser.Output_attributeContext output_attributeContext : ctx.output_attribute()) {
        attributeList.add((OutputAttribute) visit(output_attributeContext));
    }
    selector.addSelectionList(attributeList);
    if (ctx.group_by() != null) {
        selector.addGroupByList((List<Variable>) visit(ctx.group_by()));
    }
    if (ctx.having() != null) {
        selector.having((Expression) visit(ctx.having()));
    }
    if (ctx.order_by() != null) {
        selector.addOrderByList((List<OrderByAttribute>) visit(ctx.order_by()));
    }
    if (ctx.limit() != null) {
        selector.limit((Constant) visit(ctx.limit()));
    }
    populateQueryContext(selector, ctx);
    return selector;
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) Variable(org.wso2.siddhi.query.api.expression.Variable) ArrayList(java.util.ArrayList) OrderByAttribute(org.wso2.siddhi.query.api.execution.query.selection.OrderByAttribute) OutputAttribute(org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute) BasicSelector(org.wso2.siddhi.query.api.execution.query.selection.BasicSelector) Selector(org.wso2.siddhi.query.api.execution.query.selection.Selector)

Example 7 with OutputAttribute

use of org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute in project siddhi by wso2.

the class SiddhiQLBaseVisitorImpl method visitGroup_by_query_selection.

@Override
public BasicSelector visitGroup_by_query_selection(@NotNull SiddhiQLParser.Group_by_query_selectionContext ctx) {
    BasicSelector selector = new BasicSelector();
    List<OutputAttribute> attributeList = new ArrayList<OutputAttribute>(ctx.output_attribute().size());
    for (SiddhiQLParser.Output_attributeContext output_attributeContext : ctx.output_attribute()) {
        attributeList.add((OutputAttribute) visit(output_attributeContext));
    }
    selector.addSelectionList(attributeList);
    if (ctx.group_by() != null) {
        selector.addGroupByList((List<Variable>) visit(ctx.group_by()));
    }
    populateQueryContext(selector, ctx);
    return selector;
}
Also used : SiddhiQLParser(org.wso2.siddhi.query.compiler.SiddhiQLParser) Variable(org.wso2.siddhi.query.api.expression.Variable) BasicSelector(org.wso2.siddhi.query.api.execution.query.selection.BasicSelector) ArrayList(java.util.ArrayList) OutputAttribute(org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute)

Aggregations

OutputAttribute (org.wso2.siddhi.query.api.execution.query.selection.OutputAttribute)6 Variable (org.wso2.siddhi.query.api.expression.Variable)6 ArrayList (java.util.ArrayList)5 ExpressionExecutor (org.wso2.siddhi.core.executor.ExpressionExecutor)4 VariableExpressionExecutor (org.wso2.siddhi.core.executor.VariableExpressionExecutor)4 Attribute (org.wso2.siddhi.query.api.definition.Attribute)4 MetaStreamEvent (org.wso2.siddhi.core.event.stream.MetaStreamEvent)3 ConstantExpressionExecutor (org.wso2.siddhi.core.executor.ConstantExpressionExecutor)3 AbstractDefinition (org.wso2.siddhi.query.api.definition.AbstractDefinition)3 MetaStateEvent (org.wso2.siddhi.core.event.state.MetaStateEvent)2 ConditionExpressionExecutor (org.wso2.siddhi.core.executor.condition.ConditionExpressionExecutor)2 DuplicateAttributeException (org.wso2.siddhi.query.api.exception.DuplicateAttributeException)2 BasicSelector (org.wso2.siddhi.query.api.execution.query.selection.BasicSelector)2 OrderByAttribute (org.wso2.siddhi.query.api.execution.query.selection.OrderByAttribute)2 Expression (org.wso2.siddhi.query.api.expression.Expression)2 SiddhiQLParser (org.wso2.siddhi.query.compiler.SiddhiQLParser)2 HashMap (java.util.HashMap)1 MetaStateEventAttribute (org.wso2.siddhi.core.event.state.MetaStateEventAttribute)1 SiddhiAppCreationException (org.wso2.siddhi.core.exception.SiddhiAppCreationException)1 AndConditionExpressionExecutor (org.wso2.siddhi.core.executor.condition.AndConditionExpressionExecutor)1