Skip to content

Commit

Permalink
MONDRIAN:
Browse files Browse the repository at this point in the history
       Recognizer.makeLevel
           For snowflakes the search for the table with the given column
               did not recurse, it only looked at direct child tables.

[git-p4: depot-paths = "//open/mondrian/": change = 3678]
  • Loading branch information
Richard Emberson committed Jun 9, 2005
1 parent e8a5ed5 commit a0737da
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions src/main/mondrian/rolap/aggmatcher/Recognizer.java
Expand Up @@ -674,7 +674,15 @@ protected void makeLevel(final JdbcSchema.Table.Column aggColumn,

aggUsage.setSymbolicName(symbolicName);

String tableAlias = aggUsage.relation.getAlias();
String tableAlias = null;
if (aggUsage.joinExp instanceof MondrianDef.Column) {
MondrianDef.Column mcolumn =
(MondrianDef.Column) aggUsage.joinExp;
tableAlias = mcolumn.table;
} else {
tableAlias = aggUsage.relation.getAlias();
}


RolapStar.Table factTable = star.getFactTable();
RolapStar.Table descTable = factTable.findDescendant(tableAlias);
Expand All @@ -696,17 +704,7 @@ protected void makeLevel(final JdbcSchema.Table.Column aggColumn,
RolapStar.Column rc = descTable.lookupColumn(factColumnName);

if (rc == null) {
// This can happen if we are looking at a collapsed dimension
// table, and the collapsed dimension in question in the
// fact table is a snowflake (not just a star), so we
// must look deeper...
for (Iterator it = descTable.getChildren(); it.hasNext(); ) {
RolapStar.Table child = (RolapStar.Table) it.next();
rc = child.lookupColumn(factColumnName);
if (rc != null) {
break;
}
}
rc = lookupInChildren(descTable, factColumnName);

}
if (rc == null) {
Expand All @@ -732,6 +730,28 @@ protected void makeLevel(final JdbcSchema.Table.Column aggColumn,
}
}

protected RolapStar.Column lookupInChildren(final RolapStar.Table table,
final String factColumnName) {
RolapStar.Column rc = null;
// This can happen if we are looking at a collapsed dimension
// table, and the collapsed dimension in question in the
// fact table is a snowflake (not just a star), so we
// must look deeper...
for (Iterator it = table.getChildren(); it.hasNext(); ) {
RolapStar.Table child = (RolapStar.Table) it.next();
rc = child.lookupColumn(factColumnName);
if (rc != null) {
break;
} else {
rc = lookupInChildren(child, factColumnName);
if (rc != null) {
break;
}
}
}
return rc;
}


// Question: what if foreign key is seen, but there are also level
// columns - is this at least is a warning.
Expand Down

0 comments on commit a0737da

Please sign in to comment.