use of org.apache.calcite.sql.SqlAsOperator in project samza by apache.
the class SamzaSqlQueryParser method getSource.
private static void getSource(SqlNode node, ArrayList<String> sourceList) {
if (node instanceof SqlJoin) {
SqlJoin joinNode = (SqlJoin) node;
ArrayList<String> sourcesLeft = new ArrayList<>();
ArrayList<String> sourcesRight = new ArrayList<>();
getSource(joinNode.getLeft(), sourcesLeft);
getSource(joinNode.getRight(), sourcesRight);
sourceList.addAll(sourcesLeft);
sourceList.addAll(sourcesRight);
} else if (node instanceof SqlIdentifier) {
sourceList.add(node.toString());
} else if (node instanceof SqlBasicCall) {
SqlBasicCall basicCall = (SqlBasicCall) node;
if (basicCall.getOperator() instanceof SqlAsOperator) {
getSource(basicCall.operand(0), sourceList);
} else if (basicCall.getOperator() instanceof SqlUnnestOperator && basicCall.operand(0) instanceof SqlSelect) {
sourceList.addAll(getSourcesFromSelectQuery(basicCall.operand(0)));
}
} else if (node instanceof SqlSelect) {
getSource(((SqlSelect) node).getFrom(), sourceList);
}
}
Aggregations