[Mondrian] The method MondrianDef.ExpressionView.getTableAlias
returns null confuse me.
=?gb2312?B?1cW9qNbQ?=
zhangjianzhong at revenco.com
Mon Sep 10 04:42:16 EDT 2007
I'm a freshman to Modrian OLAP.
In my project I defined a "Dimension"
<Dimension name="Brand">
<Hierarchy hasAll="true" primaryKey="BRND_CD"
primaryKeyTable="REF_TR_BRND">
<Join leftKey="COOPR_CD" rightKey="COOPR_CD">
<Table name="TR_BRND" schema="REF" alias="REF_TR_BRND" />
<Table name="TR_COOPR" schema="REF" alias="REF_TR_COOPR" />
</Join>
<Level name="Cooprator" column="COOPR_CD"
uniqueMembers="true" table="REF_TR_COOPR">
<KeyExpression>
<SQL dialect="db2">RTRIM(REF_TR_COOPR.COOPR_CD)</SQL>
</KeyExpression>
<Property name="Cooprator Name"
column="COOPR_NAM" type="String" />
</Level>
<Level name="Brand" column="BRND_CD"
uniqueMembers="true" table="REF_TR_BRND">
<Property name="Brand Name" column="BRND_NAM"
type="String"/>
</Level>
</Hierarchy>
</Dimension>
it refers two tables so I used a "Join" relation, then 'cause the datas in
the column "COOPR_CD" have spcaces ,so I use a KeyExpression
then my nightmare began , when I query my cube using MDX :
"
select {[Brand].Members} ON ROWS
from [Communication User Count Daily Analysis];
"
Mondrian show me a error tip
"Mondrian Error:Internal error: bad relation type null"
I debug the code ,tracing again again. To my surprise, I found that in the
source code ,the logical seems something confusing and I just fall in the
pit... Let me show you.
In class RolapHierarchy , the method addToFrom follows it's statement,then
it use the "expression.getTableAlias()", which always returns a "null" .
which leads the error "bad relation type null" in the following method
addFrom.
Could you help me make the method MondrianDef.ExpressionView.getTableAlias
available ?
thanks
void addToFrom(SqlQuery query, MondrianDef.Expression expression) {
if (relation == null) {
throw Util.newError(
"cannot add hierarchy " + getUniqueName() +
" to query: it does not have a <Table>, <View> or
<Join>");
}
final boolean failIfExists = false;
MondrianDef.Relation subRelation = relation;
if (relation instanceof MondrianDef.Join) {
if (expression != null) {
// Suppose relation is
// (((A join B) join C) join D)
// and the fact table is
// F
// and our expression uses C. We want to make the expression
// F left join ((A join B) join C).
// Search for the smallest subset of the relation which
// uses C.
subRelation = relationSubset(relation,
expression.getTableAlias());
}
}
query.addFrom(subRelation, null, failIfExists);
}
public boolean addFrom(final MondrianDef.Relation relation,
final String alias,
final boolean failIfExists)
{
if (relation instanceof MondrianDef.View) {
final MondrianDef.View view = (MondrianDef.View) relation;
final String viewAlias = (alias == null)
? view.getAlias()
: alias;
final String sqlString = view.getCodeSet().chooseQuery(dialect);
return addFromQuery(sqlString, viewAlias, false);
} else if (relation instanceof MondrianDef.Table) {
final MondrianDef.Table table = (MondrianDef.Table) relation;
final String tableAlias = (alias == null)
? table.getAlias()
: alias;
return addFromTable(table.schema, table.name, tableAlias,
table.getFilter(), failIfExists);
} else if (relation instanceof MondrianDef.Join) {
final MondrianDef.Join join = (MondrianDef.Join) relation;
final String leftAlias = join.getLeftAlias();
final String rightAlias = join.getRightAlias();
boolean addLeft = addFrom(join.left, leftAlias, failIfExists);
boolean addRight = addFrom(join.right, rightAlias,
failIfExists);
boolean added = addLeft || addRight;
if (added) {
buf.setLength(0);
dialect.quoteIdentifier(leftAlias, join.leftKey, buf);
buf.append(" = ");
dialect.quoteIdentifier(rightAlias, join.rightKey, buf);
addWhere(buf.toString());
}
return added;
} else {
throw Util.newInternal("bad relation type " + relation);
}
}
ÕŽ¨ÖÐ
¹ãÖÝ´ÓÐ˵ç×Ó¿ª·¢ÓÐÏÞ¹«Ë¾ BIÑз¢²¿
GuangZhou Sunrise Electronics Development CO.,LTD
( 020-8711-6417 13560042989
* zhangjianzhong at revenco.com
+¹ãÖÝ´óµÀÄÏ368ºÅ14F , 510300
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20070910/fb3206a5/attachment-0001.html
More information about the Mondrian
mailing list