【发布时间】:2013-12-23 03:46:52
【问题描述】:
让 mondrian 与父子层次结构一起工作的一些问题。
我的表结构如下(简化,因为Category表实际上是一个MPTT):
RESPONSE QUESTION CATEGORY
-------------- ------------------- ----------
id ¡---> identifier (String) ¡---> id <---¡
question_id ___| category_id _____| parent_id _|
value (Measure) title name_en
我的闭包表是一个简单的设置:child_id, parent_id, distance(主键是元组 (child_id, parent_id) )。
我的多维数据集的架构如下:
<Cube cache="true"
defaultMeasure="Value" enabled="true" name="mycube">
<Table name="response" schema="public"/>
<Dimension foreignKey="question_id" name="Category">
<Hierarchy allMemberName="All Categories" hasAll="true"
primaryKey="identifier" primaryKeyTable="question">
<Join leftKey="category_id" rightKey="id">
<Table name="question"/>
<Table name="category"/>
</Join>
<!-- works fine with the category itself: <Level column="name" type="String" name="Category Name" table="category" uniqueMembers="true"/> -->
<Level column="id" name="Category ID"
nameColumn="name_en" nullParentValue="NULL"
parentColumn="parent_id" table="category"
type="Numeric" uniqueMembers="true">
<!-- type="Numeric" ordinalColumn="lft" parentColumn="parent_id" nullParentValue="NULL" -->
<Closure childColumn="child_id" parentColumn="parent_id">
<Table name="category_closure"/>
</Closure>
</Level>
</Hierarchy>
</Dimension>
<Measure aggregator="avg" caption="Value"
column="actual_value" formatString="#,###.00" name="Value"/>
</Cube>
现在,基于 mondrian FoodMart 测试页面,我为我的多维数据集设置了一个简单的 jsp 页面,我想将其用作测试的起点。它具有以下 MDX:
select {[Measures].[Value]} ON COLUMNS,
{( [Category] )} ON ROWS
from [mycube]
它最初显示的结果是“所有类别”。当我尝试在类别中向下钻取或分层时,它只返回 [所有类别]。我也尝试过 Descendants() 无济于事。 同样,当我尝试列出类别的成员时,它什么也不返回。
我看到它在后台运行如下查询以开始向下钻取:
05/12/13 23:53:10,967 postgres:[3-1] 日志:执行:选择 "category"."id" 为 "c0","category"."name_en" 为 "c1" 来自 "question" 作为“问题”,“类别”作为“类别”,其中“问题”。“类别ID” = "category"."id" and "category"."parent_id" IS NULL group by "category"."id", "category"."name_en" order by "category"."id" ASC NULLS LAST
显然,此查询的结果为空,因为它将问题与根级类别连接起来,而只有我的树的叶子附加了一些问题。 也说明这里没有用到闭包表。
有什么线索可以解决这个问题吗?
先谢谢了 来了
【问题讨论】:
标签: parent-child mdx hierarchy pentaho mondrian