Search in sources :

Example 1 with BLangTableQuery

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

the class BLangPackageBuilder method endTableQueryNode.

public void endTableQueryNode(boolean isJoinClauseAvailable, boolean isSelectClauseAvailable, boolean isOrderByClauseAvailable, DiagnosticPos pos, Set<Whitespace> ws) {
    BLangTableQuery tableQuery = (BLangTableQuery) this.tableQueriesStack.peek();
    tableQuery.pos = pos;
    tableQuery.addWS(ws);
    tableQuery.setStreamingInput(this.streamingInputStack.pop());
    if (isJoinClauseAvailable) {
        tableQuery.setJoinStreamingInput(this.joinStreamingInputsStack.pop());
    }
    if (isSelectClauseAvailable) {
        tableQuery.setSelectClause(this.selectClausesStack.pop());
    }
    if (isOrderByClauseAvailable) {
        tableQuery.setOrderByClause(this.orderByClauseStack.pop());
    }
}
Also used : BLangTableQuery(org.wso2.ballerinalang.compiler.tree.clauses.BLangTableQuery)

Example 2 with BLangTableQuery

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

Example 3 with BLangTableQuery

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

the class SqlQueryBuilder method visit.

@Override
public void visit(BLangTableQueryExpression tableQueryExpression) {
    orderByClause = null;
    whereClause = null;
    joinStreamingInputClause = null;
    streamingInputClause = null;
    selectExprClause = null;
    selectExpr = null;
    groupByClause = null;
    havingClause = null;
    selectExprParams = new ArrayList<>();
    havingExprParams = new ArrayList<>();
    joinOnExprParams = new ArrayList<>();
    exprParams = new ArrayList<>();
    whereExprParams = new ArrayList<>();
    exprStack = new Stack<>();
    BLangTableQuery tableQuery = ((BLangTableQuery) tableQueryExpression.getTableQuery());
    tableQuery.accept(this);
    tableQueryExpression.setSqlQuery(tableQuery.getSqlQuery());
    tableQueryExpression.addParams(tableQuery.getParams());
}
Also used : BLangTableQuery(org.wso2.ballerinalang.compiler.tree.clauses.BLangTableQuery)

Example 4 with BLangTableQuery

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

the class TypeChecker method visit.

@Override
public void visit(BLangTableQueryExpression tableQueryExpression) {
    BType actualType = symTable.errType;
    int expTypeTag = expTypes.get(0).tag;
    if (expTypeTag == TypeTags.TABLE) {
        actualType = expTypes.get(0);
    } else if (expTypeTag != TypeTags.ERROR) {
        dlog.error(tableQueryExpression.pos, DiagnosticCode.INCOMPATIBLE_TYPES_CONVERSION, expTypes.get(0));
    }
    BLangTableQuery tableQuery = (BLangTableQuery) tableQueryExpression.getTableQuery();
    tableQuery.accept(this);
    resultTypes = types.checkTypes(tableQueryExpression, Lists.of(actualType), expTypes);
}
Also used : BLangTableQuery(org.wso2.ballerinalang.compiler.tree.clauses.BLangTableQuery) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType)

Example 5 with BLangTableQuery

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

the class TypeChecker method visit.

@Override
public void visit(BLangTableQuery tableQuery) {
    BLangStreamingInput streamingInput = (BLangStreamingInput) tableQuery.getStreamingInput();
    streamingInput.accept(this);
    BLangJoinStreamingInput joinStreamingInput = (BLangJoinStreamingInput) tableQuery.getJoinStreamingInput();
    if (joinStreamingInput != null) {
        joinStreamingInput.accept(this);
    }
}
Also used : BLangJoinStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput) BLangStreamingInput(org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)

Aggregations

BLangTableQuery (org.wso2.ballerinalang.compiler.tree.clauses.BLangTableQuery)4 BLangJoinStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangJoinStreamingInput)2 BLangStreamingInput (org.wso2.ballerinalang.compiler.tree.clauses.BLangStreamingInput)2 TableQuery (org.ballerinalang.model.tree.clauses.TableQuery)1 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)1 BLangOrderBy (org.wso2.ballerinalang.compiler.tree.clauses.BLangOrderBy)1 BLangSelectClause (org.wso2.ballerinalang.compiler.tree.clauses.BLangSelectClause)1