<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.6000.16527" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2>Zhang Jian Zhong,</FONT></SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2><SPAN
class=885123706-12092007></SPAN></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2><SPAN class=885123706-12092007></SPAN>You're definitely
seeing a bug. I think your schema is valid, but mondrian isn't handling it
correctly - the relation parameter in the methods you cited should never be
null. Even if your schema were invalid, mondrian should give a better error
message than that.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2>I have a hunch that what is causing the bug is that the
aliases are different from the table names. Change the table aliases to be the
same as the table names, and I think the problem will go away. Let us know if
that works.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2></FONT></SPAN> </DIV></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2>Please log a bug at <A
href="http://sourceforge.net/tracker/?group_id=35302&atid=414613">http://sourceforge.net/tracker/?group_id=35302&atid=414613</A> so
that this problem gets fixed.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=885123706-12092007><FONT face=Verdana
color=#000080 size=2>Julian</FONT></SPAN></DIV><BR>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000080 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> mondrian-bounces@pentaho.org
[mailto:mondrian-bounces@pentaho.org] <B>On Behalf Of </B>Eduardo
Andrade<BR><B>Sent:</B> Monday, September 10, 2007 1:52 AM<BR><B>To:</B>
Mondrian developer mailing list<BR><B>Subject:</B> Re: [Mondrian] The method
MondrianDef.ExpressionView.getTableAliasreturns null confuse
me.<BR></FONT><BR></DIV>
<DIV></DIV>Hello,<BR><BR>I also had the same problem. This is related to using
a KeyExpression, ParentExpression, etc. inside a Dimension with a Join.<BR>If
you remove the KeyExpression, probably everything's fine. Not sure what's
supposed to happen here, maybe someone from the developing team would know.
<BR><BR>Just a thought : If you create a View in your Database that is a inner
join of the two tables involved in the dimension, you'll be able to use it as
a dimension table and eliminate this problem also (this way you may use the
KeyExpression). <BR><BR>Best regards,<BR>Eduardo Andrade<BR><BR><BR>
<DIV><SPAN class=gmail_quote>On 9/10/07, <B class=gmail_sendername>张建中</B>
<<A
href="mailto:zhangjianzhong@revenco.com">zhangjianzhong@revenco.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN>I'm a freshman to Modrian
OLAP. </SPAN></DIV>
<DIV><SPAN>In my project I defined
a "Dimension" </SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN><Dimension name="Brand"><BR> <Hierarchy
hasAll="true" primaryKey="BRND_CD"
primaryKeyTable="REF_TR_BRND"><BR> <Join
leftKey="COOPR_CD"
rightKey="COOPR_CD"><BR> <Table name="TR_BRND"
schema="REF" alias="REF_TR_BRND" /><BR> <Table
name="TR_COOPR" schema="REF" alias="REF_TR_COOPR"
/><BR> </Join><BR> <Level
name="Cooprator"
column="COOPR_CD"<BR> uniqueMembers="true"
table="REF_TR_COOPR"><BR> <KeyExpression><BR> <SQL
dialect="db2">RTRIM(REF_TR_COOPR.COOPR_CD)</SQL><BR> </KeyExpression><BR> <Property
name="Cooprator Name"<BR> column="COOPR_NAM"
type="String"
/><BR> </Level><BR> <Level
name="Brand"
column="BRND_CD"<BR> uniqueMembers="true"
table="REF_TR_BRND"><BR> <Property name="Brand
Name"
column="BRND_NAM"<BR> type="String"/><BR> </Level><BR> </Hierarchy><BR> </Dimension></SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>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</SPAN></DIV>
<DIV><SPAN>then my nightmare began , when I query my
cube using MDX : </SPAN></DIV>
<DIV><SPAN>"</SPAN></DIV>
<DIV><SPAN>select {[Brand].Members} ON ROWS<BR>from [Communication
User Count Daily Analysis];</SPAN></DIV>
<DIV><SPAN>"</SPAN></DIV>
<DIV><SPAN> Mondrian show me a error tip </SPAN></DIV>
<DIV><SPAN>"Mondrian Error:Internal error: bad relation type null"
</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>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.</SPAN></DIV>
<DIV><SPAN><FONT face=Verdana color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN>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 </SPAN><SPAN> "bad
relation type null" in the following method addFrom.</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>Could you help me make the method
MondrianDef.ExpressionView.getTableAlias available ? </SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>thanks</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN>void addToFrom(SqlQuery query, MondrianDef.Expression expression)
{<BR> if (relation == null)
{<BR>
throw
Util.newError(<BR>
"cannot add hierarchy " + getUniqueName()
+<BR>
" to query: it does not have a <Table>, <View> or
<Join>");<BR>
}<BR> final boolean failIfExists =
false;<BR> MondrianDef.Relation
subRelation = relation;<BR> if
(relation instanceof MondrianDef.Join)
{<BR> if
(expression != null)
{<BR>
// Suppose relation
is<BR>
// (((A join B) join C) join
D)<BR>
// and the fact table
is<BR>
//
F<BR>
// and our expression uses C. We want to make the
expression<BR>
// F left join ((A join B) join
C).<BR>
// Search for the smallest subset of the relation
which<BR>
// uses
C.<BR>
subRelation = relationSubset(relation,
expression.getTableAlias());</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
}<BR>
}<BR> query.addFrom(subRelation,
null, failIfExists);<BR> }</SPAN></DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN><FONT face=Verdana color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN></SPAN> </DIV>
<DIV><SPAN><FONT face=Verdana color=#000080
size=2></FONT></SPAN> </DIV>
<DIV><SPAN>public boolean addFrom(final MondrianDef.Relation
relation,<BR>
final String
alias,<BR>
final boolean failIfExists)<BR>
{<BR> if (relation instanceof
MondrianDef.View)
{<BR>
final MondrianDef.View view = (MondrianDef.View)
relation;<BR>
final String viewAlias = (alias ==
null)<BR>
?
view.getAlias()<BR>
:
alias;<BR>
final String sqlString =
view.getCodeSet().chooseQuery(dialect);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
return addFromQuery(sqlString, viewAlias, false);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> } else if (relation
instanceof MondrianDef.Table)
{<BR>
final MondrianDef.Table table = (MondrianDef.Table)
relation;<BR>
final String tableAlias = (alias ==
null)<BR>
?
table.getAlias()<BR>
: alias;</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
return addFromTable(table.schema, <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://table.name" target=_blank>table.name</A>,
tableAlias,<BR>
table.getFilter(), failIfExists);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> } else if (relation
instanceof MondrianDef.Join)
{<BR>
final MondrianDef.Join join = (MondrianDef.Join)
relation;<BR>
final String leftAlias =
join.getLeftAlias();<BR>
final String rightAlias = join.getRightAlias();</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
boolean addLeft = addFrom(join.left, leftAlias,
failIfExists);<BR>
boolean addRight = addFrom(join.right, rightAlias,
failIfExists);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
boolean added = addLeft ||
addRight;<BR>
if (added)
{<BR>
buf.setLength(0);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
dialect.quoteIdentifier(leftAlias, join.leftKey,
buf);<BR>
buf.append(" =
");<BR>
dialect.quoteIdentifier(rightAlias, join.rightKey, buf);</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN>
addWhere(buf.toString());<BR>
}<BR>
return added;</SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN> } else
{<BR>
throw Util.newInternal("bad relation type " +
relation);<BR>
}<BR> }<BR></SPAN></DIV>
<DIV><SPAN></SPAN><SPAN> </SPAN><SPAN> </SPAN></DIV>
<DIV> </DIV>
<DIV align=left>
<DIV align=left>
<TABLE
style="BACKGROUND: rgb(240,249,249) 0% 50%; WIDTH: 99%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"
cellSpacing=0 cellPadding=0 width="99%" align=left bgColor=#f0f9f9
border=0><TBODY>
<TR height=20>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: rgb(0,153,153) 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"
bgColor=#009999 height=20>
<P><B><FONT face=Arial color=white><SPAN lang=EN-US
style="FONT-WEIGHT: bold; COLOR: white; FONT-FAMILY: Arial; LETTER-SPACING: 1.5pt"><FONT
face=宋体>张建中</FONT> </SPAN></FONT></B><B><FONT face=宋体
color=white> <SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: white; LETTER-SPACING: 1.5pt"></SPAN></FONT></B></P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<P><FONT face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"></SPAN></FONT> </P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<P><B><FONT face=宋体 color=#336666 size=1><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: rgb(51,102,102)"> 广州从兴电子开发有限公司</SPAN></FONT></B><B><FONT
face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial">
BI</SPAN></FONT></B><B><FONT face=宋体 color=#336666 size=1><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: rgb(51,102,102)">研发部</SPAN></FONT></B><B><FONT
face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial">
</SPAN></FONT></B></P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<P><FONT face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"> GuangZhou
Sunrise Electronics Development
CO.,LTD<SPAN></SPAN></SPAN></FONT></P></TD></TR>
<TR height=19>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"
vAlign=bottom height=19>
<P><B><FONT face=Verdana color=#336666 size=1><SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana"> </SPAN></FONT></B><B><FONT
face=黑体 color=teal size=1> <SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: teal"><SPAN
lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: Wingdings">(</SPAN><B><FONT
face=Verdana color=#336666 size=1> <SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana"></SPAN></FONT></B></SPAN></FONT></B><B><FONT
face=Verdana color=#336666 size=1><SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana">020-8711-6417
13560042989</SPAN></FONT></B></P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<P><FONT face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"> </SPAN></FONT><FONT
face=黑体 color=teal size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: teal"> <SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: Wingdings">*</SPAN></SPAN></FONT><FONT
face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial">
</SPAN></FONT><B><FONT face=Verdana color=#336666 size=1><SPAN
lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana"><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:zhangjianzhong@revenco.com"
target=_blank>zhangjianzhong@revenco.com</A></SPAN></FONT></B><FONT
face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"></SPAN></FONT></P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<P><FONT face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"> </SPAN></FONT><FONT
face=黑体 color=teal size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: teal"> <SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: teal; FONT-FAMILY: Wingdings">+</SPAN></SPAN></FONT><FONT
face=宋体 color=#336666 size=1><SPAN
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102)">广州大道南</SPAN></FONT><B>
<FONT face=Verdana color=#336666 size=1><SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana">368</SPAN></FONT></B><FONT
face=宋体 color=#336666 size=1><SPAN
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102)">
号</SPAN></FONT><B><FONT face=Verdana color=#336666 size=1><SPAN
lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana">14F</SPAN></FONT></B><FONT
face=Arial color=#336666 size=1> <SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"></SPAN></FONT><FONT
face=黑体 color=teal size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: teal">,</SPAN></FONT><FONT face=Arial
color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial">
</SPAN></FONT><B><FONT face=Verdana color=#336666 size=1><SPAN
lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 7.5pt; COLOR: rgb(51,102,102); FONT-FAMILY: Verdana">510300</SPAN></FONT></B><FONT
face=Arial color=#336666 size=1> <SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"></SPAN></FONT></P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
<P><FONT face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"></SPAN></FONT> </P></TD></TR>
<TR>
<TD
style="PADDING-RIGHT: 0cm; PADDING-LEFT: 0cm; BACKGROUND: rgb(163,218,218) 0% 50%; PADDING-BOTTOM: 0cm; PADDING-TOP: 0cm; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial"
bgColor=#a3dada>
<P><FONT face=Arial color=#336666 size=1><SPAN lang=EN-US
style="FONT-SIZE: 9pt; COLOR: rgb(51,102,102); FONT-FAMILY: Arial"></SPAN></FONT> </P></TD></TR></TBODY></TABLE></DIV>
<P><FONT face="Times New Roman" color=navy size=2><SPAN lang=EN-US
style="FONT-SIZE: 10.5pt; COLOR: navy"></SPAN></FONT><SPAN
lang=EN-US></SPAN> </P>
<P style="MARGIN-LEFT: 21pt; TEXT-ALIGN: left" align=left><FONT face=宋体
size=2><SPAN lang=EN-US
style="FONT-SIZE: 10pt"></SPAN></FONT> </P></DIV>
<DIV> </DIV></DIV><BR>_______________________________________________<BR>Mondrian
mailing list<BR><A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:Mondrian@pentaho.org">Mondrian@pentaho.org</A><BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://lists.pentaho.org/mailman/listinfo/mondrian"
target=_blank>http://lists.pentaho.org/mailman/listinfo/mondrian</A><BR><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Eduardo Andrade<BR><A
href="mailto:eduardofandrade@gmail.com">eduardofandrade@gmail.com</A>
</BLOCKQUOTE></BODY></HTML>