[Mondrian] The methodMondrianDef.ExpressionView.getTableAliasreturns null confuse me.

Peter Tran ptran at prospricing.com
Wed Sep 12 07:49:38 EDT 2007


Zhang,

 

Mondrian is open-source, so you can get the source code and make the appropriate change, test it, and submit it for check-in.  This will be the fastest way for you to get up and running.  

 

Everyone on this list is extremely helpful and will offer guidance.

 

Thanks,

-Peter

 

________________________________

From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On Behalf Of ???
Sent: Wednesday, September 12, 2007 6:47 AM
To: 'Mondrian developer mailing list'
Subject: 答复: [Mondrian] The methodMondrianDef.ExpressionView.getTableAliasreturns null confuse me.

 

hello, Julian

 

I have done it following your guidance, unluckily it dosen't work, neither.

 

'cause in code 

 subRelation = relationSubset(relation, expression.getTableAlias());

 

 expression.getTableAilas() can never get the table alias,

 'cause in the class ExpressionViews the method getTableAlias is not implemented, 

which always returns null.

 

so subRelation = null;

then in the mothed 

 

query.addFrom(subRelation, null, failIfExists);

 

cause subRelation is null, it always throws the exception

 

throw Util.newInternal("bad relation type " + relation);

 

I have logged this bug. I wish you fix as soon as possible , thanks. 

 

Best regards,

Zhang Jianzhong

 

张建中 

 

 广州从兴电子开发有限公司 BI研发部

 GuangZhou Sunrise Electronics Development CO.,LTD

 * 020-8711-6417  13560042989

 * zhangjianzhong at revenco.com

 *广州大道南368号14F , 510300

 

 

 

 

 

 

________________________________

发件人: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] 代表 Julian Hyde
发送时间: 2007年9月12日 14:44
收件人: 'Mondrian developer mailing list'
主题: RE: [Mondrian] The methodMondrianDef.ExpressionView.getTableAliasreturns null confuse me.

Zhang Jian Zhong,

 

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.

 

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.

 

Please log a bug at http://sourceforge.net/tracker/?group_id=35302&atid=414613 so that this problem gets fixed.

 

Julian

	 

	
________________________________


	From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On Behalf Of Eduardo Andrade
	Sent: Monday, September 10, 2007 1:52 AM
	To: Mondrian developer mailing list
	Subject: Re: [Mondrian] The method MondrianDef.ExpressionView.getTableAliasreturns null confuse me.

	Hello,
	
	I also had the same problem. This is related to using a KeyExpression, ParentExpression, etc. inside a Dimension with a Join.
	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. 
	
	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). 
	
	Best regards,
	Eduardo Andrade
	
	

	On 9/10/07, 张建中 <zhangjianzhong at revenco.com> wrote: 

	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 

 

 

	 

	 

	 

	
	_______________________________________________
	Mondrian mailing list
	Mondrian at pentaho.org
	http://lists.pentaho.org/mailman/listinfo/mondrian

	
	
	
	-- 
	Eduardo Andrade
	eduardofandrade at gmail.com 


____ KILL邮件安全网关 已经扫描了这封邮件 ____



The information contained in this email may be confidential and/or legally privileged. It has been sent for the sole use of the intended recipient(s). If the reader of this message is not an intended recipient, you are hereby notified that any unauthorized review, use, disclosure, dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please contact the sender by reply email and destroy all copies of the original message. Thank you


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20070912/d99f2324/attachment.html 


More information about the Mondrian mailing list