Search in sources :

Example 1 with Selector

use of org.ballerinalang.siddhi.query.api.execution.query.selection.Selector in project ballerina by ballerina-lang.

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.ballerinalang.siddhi.query.compiler.SiddhiQLParser) Variable(org.ballerinalang.siddhi.query.api.expression.Variable) ArrayList(java.util.ArrayList) OrderByAttribute(org.ballerinalang.siddhi.query.api.execution.query.selection.OrderByAttribute) OutputAttribute(org.ballerinalang.siddhi.query.api.execution.query.selection.OutputAttribute) BasicSelector(org.ballerinalang.siddhi.query.api.execution.query.selection.BasicSelector) Selector(org.ballerinalang.siddhi.query.api.execution.query.selection.Selector)

Example 2 with Selector

use of org.ballerinalang.siddhi.query.api.execution.query.selection.Selector in project ballerina by ballerina-lang.

the class SiddhiQLBaseVisitorImpl method visitStore_query.

@Override
public Object visitStore_query(SiddhiQLParser.Store_queryContext ctx) {
    StoreQuery storeQuery = StoreQuery.query().from((InputStore) visit(ctx.store_input()));
    if (ctx.query_section() != null) {
        storeQuery = storeQuery.select((Selector) visit(ctx.query_section()));
    }
    populateQueryContext(storeQuery, ctx);
    return storeQuery;
}
Also used : StoreQuery(org.ballerinalang.siddhi.query.api.execution.query.StoreQuery) BasicSelector(org.ballerinalang.siddhi.query.api.execution.query.selection.BasicSelector) Selector(org.ballerinalang.siddhi.query.api.execution.query.selection.Selector)

Aggregations

BasicSelector (org.ballerinalang.siddhi.query.api.execution.query.selection.BasicSelector)2 Selector (org.ballerinalang.siddhi.query.api.execution.query.selection.Selector)2 ArrayList (java.util.ArrayList)1 StoreQuery (org.ballerinalang.siddhi.query.api.execution.query.StoreQuery)1 OrderByAttribute (org.ballerinalang.siddhi.query.api.execution.query.selection.OrderByAttribute)1 OutputAttribute (org.ballerinalang.siddhi.query.api.execution.query.selection.OutputAttribute)1 Variable (org.ballerinalang.siddhi.query.api.expression.Variable)1 SiddhiQLParser (org.ballerinalang.siddhi.query.compiler.SiddhiQLParser)1