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());
}
}
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());
}
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());
}
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);
}
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);
}
}
Aggregations