* testUpdateTable
*/
public void testUpdateTable() throws Exception {
Set<Table> targets = new HashSet<Table>();
for (String table_name : new String[]{ TM1Constants.TABLENAME_SUBSCRIBER, TM1Constants.TABLENAME_ACCESS_INFO }) {
Table catalog_tbl = this.getTable(table_name);
cp.update(catalog_tbl);
targets.add(catalog_tbl);
} // FOR
// Make sure that the columns that remain for the edges to our target tables
// are only connected through the column that the target tables were partitioned on
Collection<Column> columns;
for (Table catalog_tbl : catalog_db.getTables()) {
if (targets.contains(catalog_tbl) || catalog_tbl.getSystable()) continue;
DesignerVertex v0 = agraph.getVertex(catalog_tbl);
try {
columns = cp.getCandidateValues(catalog_tbl, Column.class);
} catch (IllegalArgumentException ex) {
continue;
}
assertNotNull(columns);
assertFalse(columns.isEmpty());
System.err.println(String.format("Examining %d columns for %s", columns.size(), catalog_tbl));
// For each column that is still available for this table, check to make sure that:
// (1) It does not have an unmarked edge to one of our target tables
// (2) If it is does have an edge to one of target tables then that edge uses the column that the table is partitioned on
for (Column catalog_col : columns) {
if (catalog_col instanceof ReplicatedColumn) continue;
Collection<DesignerEdge> edges = agraph.findEdgeSet(v0, catalog_col);
assertNotNull(catalog_col.fullName(), edges);
assertFalse(catalog_col.fullName(), edges.isEmpty());
for (DesignerEdge e : edges) {
if (cp.isMarked(e)) continue;
DesignerVertex v1 = agraph.getOpposite(v0, e);
assertNotNull(e.toString(), v1);
Table other_tbl = v1.getCatalogItem();
assertNotNull(other_tbl);
// Skip if not one of our target tables
if (targets.contains(other_tbl) == false || other_tbl.getPartitioncolumn() == null) continue;
// Get the ColumnSet, which should only have one entry
PredicatePairs cset = e.getAttribute(EdgeAttributes.COLUMNSET);
assertNotNull(cset);
assertEquals(cset.toString(), 1, cset.size());
CatalogPair entry = cset.get(0);
assertNotNull(entry);
// Get the element from the entry that is not our column
CatalogType other = entry.getOther(catalog_col);
assertNotNull(other);
if ((other instanceof Column) == false) continue;
Column other_col = (Column)other;
System.err.println(String.format("catalog_col=%s, other_tbl=%s, other_col=%s",
catalog_col.fullName(), other_tbl.fullName(), other_col.fullName()));
assertEquals(e.toString(), other_tbl, other_col.getParent());
// Make sure that the table's partitioning column matches
assertEquals(String.format("%s<-->%s\n%s", catalog_tbl, other_tbl, e.toString()), other_tbl.getPartitioncolumn(), other_col);
} // FOR (Edge)
} // FOR (Column)
} // FOR
}