Search in sources :

Example 1 with BLangGroupBy

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

public void visit(BLangSelectClause selectClause) {
    GroupByNode groupByNode = selectClause.getGroupBy();
    if (groupByNode != null) {
        ((BLangGroupBy) groupByNode).accept(this);
    }
    HavingNode havingNode = selectClause.getHaving();
    if (havingNode != null) {
        ((BLangHaving) havingNode).accept(this);
    }
    List<? extends SelectExpressionNode> selectExpressionsList = selectClause.getSelectExpressions();
    if (selectExpressionsList != null) {
        for (SelectExpressionNode selectExpressionNode : selectExpressionsList) {
            ((BLangSelectExpression) selectExpressionNode).accept(this);
        }
    }
}
Also used : HavingNode(org.ballerinalang.model.tree.clauses.HavingNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangSelectExpression(org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectExpression) GroupByNode(org.ballerinalang.model.tree.clauses.GroupByNode) BLangGroupBy(org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy) BLangHaving(org.wso2.ballerinalang.compiler.tree.clauses.BLangHaving)

Example 2 with BLangGroupBy

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy in project ballerina by ballerina-lang.

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangGroupBy groupBy) {
    List<? extends ExpressionNode> varList = groupBy.getVariables();
    Iterator<? extends ExpressionNode> iterator = varList.iterator();
    groupByClause = new StringBuilder("group by ");
    BLangSimpleVarRef simpleVarRef = (BLangSimpleVarRef) iterator.next();
    addVarRefToClauseBuilder(simpleVarRef, groupByClause);
    while (iterator.hasNext()) {
        simpleVarRef = (BLangSimpleVarRef) iterator.next();
        groupByClause.append(", ");
        addVarRefToClauseBuilder(simpleVarRef, groupByClause);
    }
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)

Example 3 with BLangGroupBy

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy in project ballerina by ballerina-lang.

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangGroupBy groupBy) {
    List<? extends ExpressionNode> varList = groupBy.getVariables();
    Iterator<? extends ExpressionNode> iterator = varList.iterator();
    groupByClause = new StringBuilder("group by ");
    BLangExpression expr = (BLangExpression) iterator.next();
    expr.accept(this);
    groupByClause.append(exprStack.pop());
    while (iterator.hasNext()) {
        expr = (BLangExpression) iterator.next();
        groupByClause.append(", ");
        expr.accept(this);
        groupByClause.append(exprStack.pop());
    }
}
Also used : BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 4 with BLangGroupBy

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy in project ballerina by ballerina-lang.

the class SqlQueryBuilder method createSQLGroupByClause.

private void createSQLGroupByClause(BLangSelectClause select) {
    BLangGroupBy groupBy = (BLangGroupBy) select.getGroupBy();
    groupBy.accept(this);
}
Also used : BLangGroupBy(org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy)

Example 5 with BLangGroupBy

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy in project ballerina by ballerina-lang.

the class TypeChecker method visit.

@Override
public void visit(BLangSelectClause selectClause) {
    List<? extends SelectExpressionNode> selectExprList = selectClause.getSelectExpressions();
    selectExprList.forEach(selectExpr -> ((BLangSelectExpression) selectExpr).accept(this));
    BLangGroupBy groupBy = (BLangGroupBy) selectClause.getGroupBy();
    if (groupBy != null) {
        groupBy.accept(this);
    }
    BLangHaving having = (BLangHaving) selectClause.getHaving();
    if (having != null) {
        having.accept(this);
    }
}
Also used : BLangGroupBy(org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy) BLangHaving(org.wso2.ballerinalang.compiler.tree.clauses.BLangHaving)

Aggregations

BLangGroupBy (org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy)4 BLangHaving (org.wso2.ballerinalang.compiler.tree.clauses.BLangHaving)2 GroupByNode (org.ballerinalang.model.tree.clauses.GroupByNode)1 HavingNode (org.ballerinalang.model.tree.clauses.HavingNode)1 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)1 BLangSelectExpression (org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectExpression)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)1