Search in sources :

Example 6 with BLangWhere

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

the class SiddhiQueryBuilder method visit.

@Override
public void visit(BLangPatternStreamingEdgeInput patternStreamingEdgeInput) {
    BLangExpression streamRef = (BLangExpression) patternStreamingEdgeInput.getStreamReference();
    streamRef.accept(this);
    streamIds.add(varRef);
    varRef = "";
    addInRefs(streamRef);
    String alias = patternStreamingEdgeInput.getAliasIdentifier();
    patternStreamingClause.append(alias).append(" = ").append(patternStreamingEdgeInput.getStreamReference());
    WhereNode whereNode = patternStreamingEdgeInput.getWhereClause();
    if (whereNode != null) {
        ((BLangWhere) whereNode).accept(this);
        patternStreamingClause.append(" ").append(whereClause);
        whereClause = new StringBuilder();
    }
    ExpressionNode expression = patternStreamingEdgeInput.getExpression();
    if (expression != null) {
        ((BLangExpression) expression).accept(this);
        patternStreamingClause.append(intRangeExpr.toString());
    }
}
Also used : SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) WhereNode(org.ballerinalang.model.tree.clauses.WhereNode) BLangWhere(org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 7 with BLangWhere

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

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangWhere where) {
    whereClause = new StringBuilder();
    whereClause.append("where ");
    BLangBinaryExpr expr = (BLangBinaryExpr) where.getExpression();
    addParametrizedSQL(expr, whereClause, whereExprParams);
}
Also used : BLangBinaryExpr(org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr)

Example 8 with BLangWhere

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

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangStreamingInput streamingInput) {
    streamingInputClause = new StringBuilder();
    BLangExpression tableReference = (BLangExpression) streamingInput.getStreamReference();
    tableReference.accept(this);
    exprStack.pop();
    streamingInputClause.append("(select * from [[tableName]]");
    WhereNode where = streamingInput.getBeforeStreamingCondition();
    if (where == null) {
        where = streamingInput.getAfterStreamingCondition();
    }
    /* for tables there can only be one whereClause and there is no windowClause.
         So we don't care about the windowClause. */
    if (where != null) {
        ((BLangWhere) where).accept(this);
        streamingInputClause.append(" ").append(whereClause);
    }
    streamingInputClause.append(")");
    if (streamingInput.getAlias() != null) {
        streamingInputClause.append(" as ").append(streamingInput.getAlias());
    }
}
Also used : WhereNode(org.ballerinalang.model.tree.clauses.WhereNode) BLangWhere(org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Aggregations

BLangWhere (org.wso2.ballerinalang.compiler.tree.clauses.BLangWhere)5 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)5 WhereNode (org.ballerinalang.model.tree.clauses.WhereNode)4 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)2 WindowClauseNode (org.ballerinalang.model.tree.clauses.WindowClauseNode)2 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)2 BLangWindow (org.wso2.ballerinalang.compiler.tree.clauses.BLangWindow)2 BLangBinaryExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr)2 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)1 BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)1