in odps-sdk-impl/odps-mapred-local/src/main/java/com/aliyun/odps/mapred/LocalJobRunner.java [595:682]
private void fillTableInfo() throws IOException {
TableInfo[] infos = new TableInfo[splitToTableInfo.size()];
splitToTableInfo.values().toArray(infos);
String project = wareHouse.getOdps().getDefaultProject();
for (FileSplit key : splitToTableInfo.keySet()) {
TableInfo info = splitToTableInfo.get(key);
if (info.getProjectName() == null) {
info.setProjectName(project);
}
Column[] schema = wareHouse.getTableMeta(info.getProjectName(), info.getTableName())
.getCols();
if (info.getCols() == null) {
conf.setInputSchema(info, schema);
info.setCols(SchemaUtils.getColumnNames(schema));
} else {
Column[] columns = new Column[info.getCols().length];
for (int k = 0; k < info.getCols().length; k++) {
String colName = info.getCols()[k];
for (Column c : schema) {
if (c.getName().equalsIgnoreCase(colName)) {
columns[k] = c;
break;
}
}
}
conf.setInputSchema(info, columns);
}
}
//fill input table
infos = InputUtils.getTables(conf);
if (infos != null) {
boolean changed = false;
for (int i = 0; i < infos.length; i++) {
TableInfo info = infos[i];
if (info.getProjectName() == null) {
changed = true;
info.setProjectName(project);
}
Column[] schema =
wareHouse.getTableMeta(info.getProjectName(), info.getTableName()).getCols();
if (info.getCols() == null) {
changed = true;
conf.setInputSchema(info, schema);
info.setCols(SchemaUtils.getColumnNames(schema));
} else {
Column[] columns = new Column[info.getCols().length];
for (int k = 0; k < info.getCols().length; k++) {
String colName = info.getCols()[k];
for (Column c : schema) {
if (c.getName().equalsIgnoreCase(colName)) {
columns[k] = c;
break;
}
}
}
conf.setInputSchema(info, columns);
}
infos[i] = info;
}
if (changed) {
InputUtils.setTables(infos, conf);
}
}
// Expand output columns.
infos = OutputUtils.getTables(conf);
if (infos == null) {
conf.setOutputSchema(new Column[]{new Column("nil", OdpsType.STRING)},
TableInfo.DEFAULT_LABEL);
} else {
for (TableInfo info : infos) {
if (info.getProjectName() == null) {
info.setProjectName(project);
}
Column[] schema = wareHouse.getTableMeta(info.getProjectName(), info.getTableName())
.getCols();
info.setCols(SchemaUtils.getColumnNames(schema));
conf.setOutputSchema(schema, info.getLabel());
}
OutputUtils.setTables(infos, conf);
}
}