org.apache.calcite.sql.SqlAsOperator Java Examples

The following examples show how to use org.apache.calcite.sql.SqlAsOperator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SamzaSqlQueryParser.java    From samza with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example #2
Source File: MergeTableLikeUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private SqlNode tableColumn(String name, SqlNode expression) {
	return new SqlBasicCall(
		new SqlAsOperator(),
		new SqlNode[]{expression, identifier(name)},
		SqlParserPos.ZERO
	);
}
 
Example #3
Source File: SideParser.java    From alchemy with Apache License 2.0 4 votes vote down vote up
private static SqlNode createNewFrom(String table, String alias, SqlNode from) {
    SqlIdentifier identifierFirst = new SqlIdentifier(table, from.getParserPosition());
    SqlIdentifier identifierSecond = new SqlIdentifier(alias, from.getParserPosition());
    return new SqlBasicCall(new SqlAsOperator(), new SqlNode[] {identifierFirst, identifierSecond}, from.getParserPosition());
}