protected RelDataType uniquifyFields(RelDataType rowType) { return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), SqlValidatorUtil.uniquify(rowType.getFieldNames())); }
fieldNames = SqlValidatorUtil.uniquify(fieldNames);
/** * Makes sure that the names in a list are unique. * * <p>Does not modify the input list. Returns the input list if the strings * are unique, otherwise allocates a new list. * * @param nameList List of strings * @return List of unique strings */ public static List<String> uniquify(List<String> nameList) { return uniquify(nameList, EXPR_SUGGESTER); }
public static List<String> uniquify( List<String> nameList, Suggester suggester) { Set<String> used = new LinkedHashSet<String>(); int changeCount = 0; for (String name : nameList) { String uniqueName = uniquify(name, used, suggester); if (!uniqueName.equals(name)) { ++changeCount; } } return changeCount == 0 ? nameList : new ArrayList<String>(used); }
/** * Makes sure that the names in a list are unique. * * <p>Does not modify the input list. Returns the input list if the strings * are unique, otherwise allocates a new list. * * @param nameList List of strings * @return List of unique strings */ public static List<String> uniquify(List<String> nameList) { Set<String> used = new LinkedHashSet<String>(); int changeCount = 0; for (int i = 0; i < nameList.size(); i++) { String name = nameList.get(i); String uniqueName = uniquify(name, used); if (!uniqueName.equals(name)) { ++changeCount; } } return changeCount == 0 ? nameList : new ArrayList<String>(used); }
/** Creates a result based on a single relational expression. */ public Result result(SqlNode node, Collection<Clause> clauses, RelNode rel) { final String alias2 = SqlValidatorUtil.getAlias(node, -1); final String alias3 = alias2 != null ? alias2 : "t"; final String alias4 = SqlValidatorUtil.uniquify( alias3, aliasSet, SqlValidatorUtil.EXPR_SUGGESTER); final String alias5 = alias2 == null || !alias2.equals(alias4) ? alias4 : null; return new Result(node, clauses, alias5, Collections.singletonList(Pair.of(alias4, rel.getRowType()))); }
/** Creates a result based on a single relational expression. */ public Result result(SqlNode node, Collection<Clause> clauses, RelNode rel) { final String alias2 = SqlValidatorUtil.getAlias(node, -1); final String alias3 = alias2 != null ? alias2 : "t"; final String alias4 = SqlValidatorUtil.uniquify(alias3, aliasSet); final String alias5 = alias2 == null || !alias2.equals(alias4) ? alias4 : null; return new Result(node, clauses, alias5, Collections.singletonList(Pair.of(alias4, rel.getRowType()))); }
public RelDataType getRowType(RelDataTypeFactory typeFactory) { final List<RelDataType> typeList = new ArrayList<RelDataType>(); final List<String> nameList = new ArrayList<String>(); final List<Integer> fieldCounts = new ArrayList<Integer>(); for (Table table : tables) { final RelDataType rowType = table.getRowType(typeFactory); typeList.addAll(RelOptUtil.getFieldTypeList(rowType)); nameList.addAll(rowType.getFieldNames()); fieldCounts.add(rowType.getFieldCount()); } // Compute fieldCounts the first time this method is called. Safe to assume // that the field counts will be the same whichever type factory is used. if (this.fieldCounts == null) { this.fieldCounts = ImmutableIntList.copyOf(fieldCounts); } return typeFactory.createStructType(typeList, SqlValidatorUtil.uniquify(nameList)); }
protected RelDataType uniquifyFields(RelDataType rowType) { final List<String> fieldNameList = new ArrayList<String>(rowType.getFieldNames()); SqlValidatorUtil.uniquify(fieldNameList); return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), fieldNameList); }
/** Equivalent to {@link CalcRel#createProject(RelNode, List, List)} * for {@link MutableRel}. */ static MutableRel of(MutableRel child, List<RexNode> exprList, List<String> fieldNameList) { final RelDataType rowType = RexUtil.createStructType(child.cluster.getTypeFactory(), exprList, fieldNameList == null ? null : SqlValidatorUtil.uniquify(fieldNameList, SqlValidatorUtil.F_SUGGESTER)); return of(rowType, child, exprList); }
/** * 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); }
protected RelDataType uniquifyFields(RelDataType rowType) { return validator.getTypeFactory().createStructType( RelOptUtil.getFieldTypeList(rowType), SqlValidatorUtil.uniquify(rowType.getFieldNames())); }
fieldNames = SqlValidatorUtil.uniquify(fieldNames);
fieldNames = SqlValidatorUtil.uniquify(fieldNames);
fieldNames == null ? null : SqlValidatorUtil.uniquify( fieldNames, SqlValidatorUtil.F_SUGGESTER)); if (optimize