【问题标题】:Mondrian parent-child hierarchy not working蒙德里安父子层次结构不起作用
【发布时间】: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


    【解决方案1】:

    经过一些实验,我将得出结论,蒙德里安可能不支持我的用例。 这是我为得出这个结论所做的测试: - 确保我的树中有 3 个级别(级别 0->2) - 创建一个与根类别相关的假问题(即其 parent_id = NULL) - 创建一个附加到这个假问题的回复 - 在这个阶段,只有级别 0 和级别 2 的类别记录有与之相关的问题和响应 - 继续查询

    这是我在日志中得到的结果:

    14:37:09,082 WARN [SqlTupleReader] 级别 [Category].[Name] 使 使用“parentColumn”属性,但键 3 的父成员是 失踪。这可能是由于使用了 NativizeSet MDX 函数 与成员列表形成一个父子层次结构,不 在其定义中包括所有父成员。将 NativizeSet 与 父子层次结构要求父成员包含在 集合,或者层次结构无法在本地正确构建。

    “key 3”与我的 2 级记录之一相关,即树叶(其他 2 级记录显示类似的消息)。

    结论:不支持:-(

    在下面包含“工作”模式:

    <Schema name="Foo">
        <Cube name="Foo" caption="Cube to report on the Foo quizz dimensions" visible="true" defaultMeasure="Rating" cache="true" enabled="true">
            <Table name="response" schema="public">
            </Table>
            <Dimension type="StandardDimension" visible="true" foreignKey="question_id" highCardinality="false" name="Category">
                <Hierarchy name="Category" visible="true" hasAll="false" allMemberName="All Categories" primaryKey="identifier" primaryKeyTable="question">
                    <Join leftKey="category_id" rightKey="id">
                        <Table name="question" schema="public">
                        </Table>
                        <Table name="category" schema="public">
                        </Table>
                    </Join>
                    <Level name="Name" visible="true" table="category" column="id" nameColumn="name" ordinalColumn="tree_id" parentColumn="parent_id" nullParentValue="NULL" type="String" uniqueMembers="true" levelType="Regular" hideMemberIf="Never">
                    </Level>
                </Hierarchy>
            </Dimension>
            <Measure name="Ratings" column="actual_value" formatString="#,###.00" aggregator="avg" caption="Ratings">
            </Measure>
        </Cube>
    </Schema>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多