/** * Adds an expression to a select list, ensuring that its alias does not * clash with any existing expressions on the list. */ protected void addToSelectList( List<SqlNode> list, Set<String> aliases, List<Map.Entry<String, RelDataType>> fieldList, SqlNode exp, SqlValidatorScope scope, final boolean includeSystemVars) { String alias = SqlValidatorUtil.getAlias(exp, -1); String uniqueAlias = SqlValidatorUtil.uniquify(alias, aliases); if (!alias.equals(uniqueAlias)) { exp = SqlValidatorUtil.addAlias(exp, uniqueAlias); } fieldList.add(Pair.of(uniqueAlias, deriveType(scope, exp))); list.add(exp); }
/** * Adds an expression to a select list, ensuring that its alias does not * clash with any existing expressions on the list. */ protected void addToSelectList( List<SqlNode> list, Set<String> aliases, List<Map.Entry<String, RelDataType>> fieldList, SqlNode exp, SqlValidatorScope scope, final boolean includeSystemVars) { String alias = SqlValidatorUtil.getAlias(exp, -1); String uniqueAlias = SqlValidatorUtil.uniquify( alias, aliases, SqlValidatorUtil.EXPR_SUGGESTER); if (!alias.equals(uniqueAlias)) { exp = SqlValidatorUtil.addAlias(exp, uniqueAlias); } fieldList.add(Pair.of(uniqueAlias, deriveType(scope, exp))); list.add(exp); }
/** * Creates the SELECT statement that putatively feeds rows into an UPDATE * statement to be updated. * * @param call Call to the UPDATE operator * @return select statement */ protected SqlSelect createSourceSelectForUpdate(SqlUpdate call) { final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(new SqlIdentifier("*", SqlParserPos.ZERO)); int ordinal = 0; for (SqlNode exp : call.getSourceExpressionList()) { // Force unique aliases to avoid a duplicate for Y with // SET X=Y String alias = SqlUtil.deriveAliasFromOrdinal(ordinal); selectList.add(SqlValidatorUtil.addAlias(exp, alias)); ++ordinal; } SqlNode sourceTable = call.getTargetTable(); if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple()); } return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable, call.getCondition(), null, null, null, null, null, null); }
/** * Creates the SELECT statement that putatively feeds rows into a DELETE * statement to be deleted. * * @param call Call to the DELETE operator * @return select statement */ protected SqlSelect createSourceSelectForDelete(SqlDelete call) { final SqlNodeList selectList = new SqlNodeList(SqlParserPos.ZERO); selectList.add(new SqlIdentifier("*", SqlParserPos.ZERO)); SqlNode sourceTable = call.getTargetTable(); if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple()); } return new SqlSelect(SqlParserPos.ZERO, null, selectList, sourceTable, call.getCondition(), null, null, null, null, null, null); }
if (call.getAlias() != null) { sourceTable = SqlValidatorUtil.addAlias( sourceTable, call.getAlias().getSimple());
SqlParserPos.ZERO); selectList.add( SqlValidatorUtil.addAlias(col, UPDATE_ANON_PREFIX + i)); ++i; new SqlSelect(SqlParserPos.ZERO, null, selectList, source, null, null, null, null, null, null, null); source = SqlValidatorUtil.addAlias(source, UPDATE_SRC_ALIAS); SqlMerge mergeCall = new SqlMerge(updateCall.getParserPosition(), target, condition, source,
if (call.getAlias() != null) { targetTable = SqlValidatorUtil.addAlias( targetTable, call.getAlias().getSimple());
if (call.getAlias() != null) { targetTable = SqlValidatorUtil.addAlias( targetTable, call.getAlias().getSimple());