Search in sources :

Example 1 with BLangSelectClause

use of org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectClause 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 BLangSelectClause

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

the class SiddhiQueryBuilder method createSiddhiHavingClause.

private void createSiddhiHavingClause(BLangSelectClause select) {
    BLangHaving having = (BLangHaving) select.getHaving();
    having.accept(this);
}
Also used : BLangHaving(org.wso2.ballerinalang.compiler.tree.clauses.BLangHaving)

Example 3 with BLangSelectClause

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

the class SiddhiQueryBuilder method createSiddhiSelectExpressionClause.

private void createSiddhiSelectExpressionClause(BLangSelectClause select) {
    List<? extends SelectExpressionNode> selectExprList = select.getSelectExpressions();
    selectExprClause = new StringBuilder();
    selectExprClause.append("select ");
    if (selectExprList != null && !selectExprList.isEmpty()) {
        Iterator<? extends SelectExpressionNode> iterator = selectExprList.iterator();
        BLangSelectExpression selectExpression = (BLangSelectExpression) iterator.next();
        selectExpression.accept(this);
        selectExprClause.append(selectExpr);
        while (iterator.hasNext()) {
            selectExpression = (BLangSelectExpression) iterator.next();
            selectExprClause.append(", ");
            selectExpression.accept(this);
            selectExprClause.append(selectExpr);
        }
    } else if (select.isSelectAll()) {
        selectExprClause.append("* ");
    }
}
Also used : BLangSelectExpression(org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectExpression)

Example 4 with BLangSelectClause

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

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangStreamingQueryStatement streamingQueryStatement) {
    siddhiQuery.append("from ");
    StreamingInput streamingInput = streamingQueryStatement.getStreamingInput();
    if (streamingInput != null) {
        ((BLangStreamingInput) streamingInput).accept(this);
        siddhiQuery.append(" ").append(streamingInputClause);
    }
    PatternClause patternClause = streamingQueryStatement.getPatternClause();
    if (patternClause != null) {
        patternStreamingClause = new StringBuilder();
        ((BLangPatternClause) patternClause).accept(this);
        siddhiQuery.append(" ").append(patternStreamingClause);
    }
    JoinStreamingInput joinStreamingInput = streamingQueryStatement.getJoiningInput();
    if (joinStreamingInput != null) {
        ((BLangJoinStreamingInput) joinStreamingInput).accept(this);
        siddhiQuery.append(" ").append(joinStreamingInputClause);
    }
    SelectClauseNode selectClauseNode = streamingQueryStatement.getSelectClause();
    if (selectClauseNode != null) {
        ((BLangSelectClause) selectClauseNode).accept(this);
        siddhiQuery.append(" ").append(selectExprClause);
    }
    OrderByNode orderByNode = streamingQueryStatement.getOrderbyClause();
    if (orderByNode != null) {
        ((BLangOrderBy) orderByNode).accept(this);
        siddhiQuery.append(" ").append(orderByClause);
    }
    OutputRateLimitNode outputRateLimitNode = streamingQueryStatement.getOutputRateLimitNode();
    if (outputRateLimitNode != null) {
        ((BLangOutputRateLimit) outputRateLimitNode).accept(this);
        siddhiQuery.append(" ").append(outputRateLimitClause);
    }
    BLangStreamAction streamActionNode = (BLangStreamAction) streamingQueryStatement.getStreamingAction();
    if (streamActionNode != null) {
        streamActionNode.accept(this);
        siddhiQuery.append(" ").append(streamActionClause);
        siddhiQuery.append(" ; ");
    }
}
Also used : OutputRateLimitNode(org.ballerinalang.model.tree.clauses.OutputRateLimitNode) OrderByNode(org.ballerinalang.model.tree.clauses.OrderByNode) BLangPatternClause(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternClause) SelectClauseNode(org.ballerinalang.model.tree.clauses.SelectClauseNode) PatternClause(org.ballerinalang.model.tree.clauses.PatternClause) BLangPatternClause(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternClause) BLangOutputRateLimit(org.wso2.ballerinalang.compiler.tree.clauses.BLangOutputRateLimit) BLangPatternStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingInput) JoinStreamingInput(org.ballerinalang.model.tree.clauses.JoinStreamingInput) BLangStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput) BLangJoinStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput) StreamingInput(org.ballerinalang.model.tree.clauses.StreamingInput) BLangSelectClause(org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectClause) BLangJoinStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput) JoinStreamingInput(org.ballerinalang.model.tree.clauses.JoinStreamingInput) BLangJoinStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput) BLangStreamAction(org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamAction) BLangOrderBy(org.wso2.ballerinalang.compiler.tree.clauses.BLangOrderBy) BLangStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)

Example 5 with BLangSelectClause

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

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangTableQuery tableQuery) {
    BLangSelectClause selectClause = (BLangSelectClause) tableQuery.getSelectClauseNode();
    BLangStreamingInput streamingInput = (BLangStreamingInput) tableQuery.getStreamingInput();
    BLangJoinStreamingInput joinStreamingInput = (BLangJoinStreamingInput) tableQuery.getJoinStreamingInput();
    BLangOrderBy orderBy = (BLangOrderBy) tableQuery.getOrderByNode();
    StringBuilder sqlTableQuery = new StringBuilder();
    /*Add each clause to the sqlQuery and add the params to TableQuery object*/
    addSelectClauseAndParams(tableQuery, selectClause, sqlTableQuery);
    addFromClauseAndParams(tableQuery, streamingInput, sqlTableQuery);
    addJoinClauseAndParams(tableQuery, joinStreamingInput, sqlTableQuery);
    addGroupByClause(selectClause, sqlTableQuery);
    addHavingClauseAndParams(tableQuery, selectClause, sqlTableQuery);
    addOrderByClause(orderBy, sqlTableQuery);
    tableQuery.setSqlQuery(sqlTableQuery.toString());
}
Also used : BLangSelectClause(org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectClause) BLangJoinStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput) BLangOrderBy(org.wso2.ballerinalang.compiler.tree.clauses.BLangOrderBy) BLangStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)

Aggregations

BLangGroupBy (org.wso2.ballerinalang.compiler.tree.clauses.BLangGroupBy)4 BLangHaving (org.wso2.ballerinalang.compiler.tree.clauses.BLangHaving)4 BLangJoinStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput)3 BLangOrderBy (org.wso2.ballerinalang.compiler.tree.clauses.BLangOrderBy)3 BLangSelectClause (org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectClause)3 BLangSelectExpression (org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectExpression)3 BLangStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)3 JoinStreamingInput (org.ballerinalang.model.tree.clauses.JoinStreamingInput)2 OrderByNode (org.ballerinalang.model.tree.clauses.OrderByNode)2 SelectClauseNode (org.ballerinalang.model.tree.clauses.SelectClauseNode)2 StreamingInput (org.ballerinalang.model.tree.clauses.StreamingInput)2 BLangPatternClause (org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternClause)2 BLangPatternStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangPatternStreamingInput)2 BLangStreamAction (org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamAction)2 GroupByNode (org.ballerinalang.model.tree.clauses.GroupByNode)1 HavingNode (org.ballerinalang.model.tree.clauses.HavingNode)1 OutputRateLimitNode (org.ballerinalang.model.tree.clauses.OutputRateLimitNode)1 PatternClause (org.ballerinalang.model.tree.clauses.PatternClause)1 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)1 StreamActionNode (org.ballerinalang.model.tree.clauses.StreamActionNode)1