typeFactory); final Map<String, Integer> nameToIndex = SqlValidatorUtil.mapNameToIndex(tableRowType.getFieldList());
/** * Creates a mapping from the view index to the index in the underlying table. */ private static ImmutableIntList getNewColumnMapping(Table underlying, ImmutableIntList oldColumnMapping, List<RelDataTypeField> extendedColumns, RelDataTypeFactory typeFactory) { final List<RelDataTypeField> baseColumns = underlying.getRowType(typeFactory).getFieldList(); final Map<String, Integer> nameToIndex = mapNameToIndex(baseColumns); final ImmutableList.Builder<Integer> newMapping = ImmutableList.builder(); newMapping.addAll(oldColumnMapping); int newMappedIndex = baseColumns.size(); for (RelDataTypeField extendedColumn : extendedColumns) { if (nameToIndex.containsKey(extendedColumn.getName())) { // The extended column duplicates a column in the underlying table. // Map to the index in the underlying table. newMapping.add(nameToIndex.get(extendedColumn.getName())); } else { // The extended column is not in the underlying table. newMapping.add(newMappedIndex++); } } return ImmutableIntList.copyOf(newMapping.build()); }
/** * Creates a mapping from the view index to the index in the underlying table. */ private static ImmutableIntList getNewColumnMapping(Table underlying, ImmutableIntList oldColumnMapping, List<RelDataTypeField> extendedColumns, RelDataTypeFactory typeFactory) { final List<RelDataTypeField> baseColumns = underlying.getRowType(typeFactory).getFieldList(); final Map<String, Integer> nameToIndex = mapNameToIndex(baseColumns); final ImmutableList.Builder<Integer> newMapping = ImmutableList.builder(); newMapping.addAll(oldColumnMapping); int newMappedIndex = baseColumns.size(); for (RelDataTypeField extendedColumn : extendedColumns) { if (nameToIndex.containsKey(extendedColumn.getName())) { // The extended column duplicates a column in the underlying table. // Map to the index in the underlying table. newMapping.add(nameToIndex.get(extendedColumn.getName())); } else { // The extended column is not in the underlying table. newMapping.add(newMappedIndex++); } } return ImmutableIntList.copyOf(newMapping.build()); }
getBaseRowType().getFieldList(); final Map<String, Integer> nameToIndex = SqlValidatorUtil.mapNameToIndex(baseFields);
getBaseRowType().getFieldList(); final Map<String, Integer> nameToIndex = SqlValidatorUtil.mapNameToIndex(baseFields);
typeFactory); final Map<String, Integer> nameToIndex = SqlValidatorUtil.mapNameToIndex(tableRowType.getFieldList());
typeFactory); final Map<String, Integer> nameToIndex = SqlValidatorUtil.mapNameToIndex(tableRowType.getFieldList());