Search in sources :

Example 1 with BLangTableQueryExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangTableQueryExpression in project ballerina by ballerina-lang.

the class Desugar method getJoinTableVarRef.

private BLangSimpleVarRef getJoinTableVarRef(BLangTableQueryExpression tableQueryExpression) {
    JoinStreamingInput joinStreamingInput = tableQueryExpression.getTableQuery().getJoinStreamingInput();
    BLangSimpleVarRef joinTable = null;
    if (joinStreamingInput != null) {
        joinTable = (BLangSimpleVarRef) joinStreamingInput.getStreamingInput().getStreamReference();
        joinTable = rewrite(joinTable, env);
    }
    return joinTable;
}
Also used : BLangSimpleVarRef(org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef) JoinStreamingInput(org.ballerinalang.model.tree.clauses.JoinStreamingInput)

Example 2 with BLangTableQueryExpression

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangTableQueryExpression in project ballerina by ballerina-lang.

the class Desugar method getReturnType.

private BLangStructLiteral getReturnType(BLangTableQueryExpression tableQueryExpression) {
    // create a literal to represent the sql query.
    BTableType tableType = (BTableType) tableQueryExpression.type;
    BStructType structType = (BStructType) tableType.constraint;
    return new BLangStructLiteral(new ArrayList<>(), structType);
}
Also used : BStructType(org.wso2.ballerinalang.compiler.semantics.model.types.BStructType) BLangStructLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral.BLangStructLiteral) BTableType(org.wso2.ballerinalang.compiler.semantics.model.types.BTableType)

Example 3 with BLangTableQueryExpression

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

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

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangTableQueryExpression in project ballerina by ballerina-lang.

the class Desugar method getSQLPreparedStatement.

private BLangLiteral getSQLPreparedStatement(BLangTableQueryExpression tableQueryExpression) {
    // create a literal to represent the sql query.
    BLangLiteral sqlQueryLiteral = (BLangLiteral) TreeBuilder.createLiteralExpression();
    sqlQueryLiteral.typeTag = TypeTags.STRING;
    // assign the sql query from table expression to the literal.
    sqlQueryLiteral.value = tableQueryExpression.getSqlQuery();
    sqlQueryLiteral.type = symTable.getTypeFromTag(sqlQueryLiteral.typeTag);
    return sqlQueryLiteral;
}
Also used : BLangLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)

Aggregations

BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)3 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)3 ArrayList (java.util.ArrayList)2 JoinStreamingInput (org.ballerinalang.model.tree.clauses.JoinStreamingInput)2 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)2 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)2 BLangTableQueryExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangTableQueryExpression)2 BLangXMLQuotedString (org.wso2.ballerinalang.compiler.tree.expressions.BLangXMLQuotedString)2 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Stack (java.util.Stack)1 Collectors (java.util.stream.Collectors)1 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)1 TreeBuilder (org.ballerinalang.model.TreeBuilder)1