@Override public SqlNode visit(SqlCall call) { if (call instanceof SqlSelect) { SqlSelect select = (SqlSelect) call; select.getFrom().accept(this); return null; } if (call instanceof SqlOrderBy) { SqlOrderBy orderBy = (SqlOrderBy) call; orderBy.query.accept(this); return null; } if (call instanceof SqlWith) { SqlWith sqlWith = (SqlWith) call; sqlWith.body.accept(this); sqlWith.withList.accept(this); } if (call instanceof SqlBasicCall) { SqlBasicCall node = (SqlBasicCall) call; node.getOperands()[0].accept(this); return null; } if (call instanceof SqlJoin) { SqlJoin node = (SqlJoin) call; node.getLeft().accept(this); node.getRight().accept(this); return null; } return null; }
/** Copies a list of nodes. */ public static SqlNodeList copy(SqlValidatorScope scope, SqlNodeList list) { //noinspection deprecation return (SqlNodeList) list.accept(new DeepCopier(scope)); }
/** Copies a list of nodes. */ public static SqlNodeList copy(SqlValidatorScope scope, SqlNodeList list) { //noinspection deprecation return (SqlNodeList) list.accept(new DeepCopier(scope)); }
private GroupBy parseGroupBy(SqlSelect sqlSelect) { GroupBy groupBy = null; SqlNodeList sqlGroupBy = sqlSelect.getGroup(); if (sqlGroupBy != null) { ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs); ExpressionList exprList = (ExpressionList) sqlGroupBy.accept(exprGenerator); groupBy = new GroupBy(exprList.getExpressions()); referredUdfs.addAll(exprGenerator.getReferredUdfs()); } LOG.debug("GroupBy {}", groupBy); return groupBy; }
private Projection parseProjection(SqlSelect sqlSelect) { Projection projection; ExpressionGenerator exprGenerator = new ExpressionGenerator(streams, catalogUdfs); ExpressionList exprList = (ExpressionList) sqlSelect.getSelectList().accept(exprGenerator); if (exprList.getExpressions().size() == 1 && exprList.getExpressions().get(0) == STAR) { projection = null; } else { projection = new Projection(exprList.getExpressions()); } referredUdfs.addAll(exprGenerator.getReferredUdfs()); LOG.debug("Projection {}", projection); return projection; }
@Override public SqlNode visit(SqlCall call) { if (call instanceof SqlSelect) { SqlSelect select = (SqlSelect) call; select.getFrom().accept(this); return null; } if (call instanceof SqlOrderBy) { SqlOrderBy orderBy = (SqlOrderBy) call; orderBy.query.accept(this); return null; } if (call instanceof SqlWith) { SqlWith sqlWith = (SqlWith) call; sqlWith.body.accept(this); sqlWith.withList.accept(this); } if (call instanceof SqlBasicCall) { SqlBasicCall node = (SqlBasicCall) call; node.getOperands()[0].accept(this); return null; } if (call instanceof SqlJoin) { SqlJoin node = (SqlJoin) call; node.getLeft().accept(this); node.getRight().accept(this); return null; } return null; }
@Override public List<String> visit(SqlCall sqlCall) { if (sqlCall instanceof SqlSelect) { ((SqlSelect) sqlCall).getSelectList().accept(this); if (((SqlSelect) sqlCall).getFrom() != null) { ((SqlSelect) sqlCall).getFrom().accept(this); } if (((SqlSelect) sqlCall).getWhere() instanceof SqlBasicCall) { List<SqlNode> operands = ((SqlBasicCall) ((SqlSelect) sqlCall).getWhere()).getOperandList(); for (SqlNode operand : operands) { if (! (operand instanceof SqlIdentifier)) { operand.accept(this); } } } } if (sqlCall instanceof SqlJoin) { ((SqlJoin) sqlCall).getLeft().accept(this); ((SqlJoin) sqlCall).getRight().accept(this); } if (sqlCall instanceof SqlBasicCall) { visitBasicCall((SqlBasicCall) sqlCall); } if (sqlCall instanceof SqlOrderBy) { ((SqlOrderBy) sqlCall).query.accept(this); } return tableNames; }