in spanner-data-validator-java/src/main/java/com/google/migration/dto/session/Schema.java [150:169]
public void computeToSource() {
// We iterate over spSchema because srcSchema might have extra tables that were dropped.
for (String tableId : spSchema.keySet()) {
SpannerTable spTable = spSchema.get(tableId);
SourceTable srcTable = srcSchema.get(tableId);
Map<String, String> cols = new HashMap<String, String>();
// We iterate over spTable columns because the source might have extra columns that were
// dropped. We only keep those columns present both in source and in spanner.
for (String colId : spTable.getColIds()) {
// We add this check because spanner can have extra columns for synthetic PK.
if (srcTable.getColDefs().containsKey(colId)) {
cols.put(
spTable.getColDefs().get(colId).getName(),
srcTable.getColDefs().get(colId).getName());
}
}
NameAndCols nameAndCols = new NameAndCols(srcTable.getName(), cols);
this.toSource.put(spTable.getName(), nameAndCols);
}
}