简体   繁体   English

Pentaho Mondrian使用汇总表

[英]Pentaho Mondrian using aggregate tables

I have xml schema description for Pentaho Mondrian. 我有Pentaho Mondrian的xml架构描述。 It looks like this: 看起来像这样:

    <Dimension foreignKey="dt" name="dt" type="TimeDimension">
    <Hierarchy allMemberName="All" hasAll="true" name="Hierarchy" primaryKey="dt" visible="true">
    <View alias="dt_view">
    <SQL dialect="generic">select distinct "dt",date_part('year', "dt")::integer AS year, date_part('month', "dt")::integer AS month, date_part('day', "dt")::integer AS day from "world_steel_production"."world_steel_production_data"
    </SQL>
    </View>
    <Level captionColumn="year" column="year" hideMemberIf="Never" levelType="TimeYears" name="Years" type="Integer" uniqueMembers="false"/>
    <Level column="month" formatter="capsidea.MemberMonthFormatter" hideMemberIf="Never" levelType="TimeMonths" name="Month" type="Integer" uniqueMembers="false"/>
    </Hierarchy>
    </Dimension>

    <Dimension foreignKey="obj" name="Index">
    <Hierarchy allMemberName="All" hasAll="true" name="name_ru" primaryKey="key" visible="true">
    <Table name="world_steel_production_dict_obj" schema="world_steel_production"/>
    <Level column="key" nameColumn="name_ru" parentColumn="parent_key" hideMemberIf="Never" levelType="Regular" name="Level" type="Integer" uniqueMembers="true"/>
    </Hierarchy>
    </Dimension>

    <Measure aggregator="sum" column="vl" name="Value" visible="true"/>

</Cube>

Our timedimension <Dimension foreignKey="dt" name="dt" type="TimeDimension"> contains two levels: "year" and "month" When I choose level "year" Mondrian aggregates data by year. 我们的时间维度<Dimension foreignKey="dt" name="dt" type="TimeDimension">包含两个级别:“年”和“月”当我选择级别“年”时,蒙德里安按年份汇总数据。

It seems fine, but table world_steel_production_data has two dynamic levels in data which defines columns dl (1 - year dynamic and 4 - month dynamic) 看起来不错,但是表world_steel_production_data在数据中具有两个动态级别,这些动态级别定义了列dl(1年动态和4月动态)

在此处输入图片说明

This case when I aggregate data by year level in 1980 contains data with year and month dynamics. 当我在1980年按年份汇总数据时,这种情况包含具有年份和月份动态的数据。

I've read ( http://mondrian.pentaho.com/documentation/aggregate_tables.php ) that Pentaho can use aggregate table and I want to use them in order to split my month and year dynamics. 我已阅读( http://mondrian.pentaho.com/documentation/aggregate_tables.php),Pentaho可以使用聚合表,并且我想使用它们来拆分我的月份和年份动态。

I've create two vies for aggregate table purpose 我已经创建了两个表来汇总表

create or replace view world_steel_production.world_steel_production_data_view_year
as 
select *
from world_steel_production.world_steel_production_data
where dl = 1

and

create or replace view world_steel_production.world_steel_production_data_view_month
as 
select *
from world_steel_production.world_steel_production_data
where dl = 4

But now I'm wandering how to say to Pentaho in my xml schema definition use the first view for year dynamics and second one for month dynamics? 但是,现在我正在徘徊如何在xml模式定义中对Pentaho说:将第一个视图用于年份动态,将第二个视图用于月份动态?

Or maybe there is another way to split year and months dynamics? 或者,也许还有另一种方式可以分解年份和月份的动态?

I think I've found the solution. 我想我已经找到了解决方案。 Mondrian has such thing as Closure tables ( http://mondrian.pentaho.com/documentation/schema.php#Closure_tables ). 蒙德里安(Mondrian)具有封闭表(Closure table)( http://mondrian.pentaho.com/documentation/schema.php#Closure_tables )之类的东西。 At this table you can define how to aggregate in your hierarchy dimension. 在此表上,您可以定义如何在层次结构维度中进行汇总。

What I've done in my situation: 我在这种情况下所做的事情:

  1. I've created and filled hierarchy table for dates and link this table with data-table in my schema. 我已经为日期创建并填充了层次结构表,并将该表与架构中的数据表链接。

在此处输入图片说明

  1. Next I've created and filled closure table. 接下来,我创建并填充了关闭表。

在此处输入图片说明

As you can see, I've filled closure table as my world_steel_production_time_hierarchy has no hierarchy at all (time_id = parent_time_id). 如您所见,由于我的world_steel_production_time_hierarchy根本没有层次结构(time_id = parent_time_id),因此我已经填写了关闭表。

  1. And at last I've changed XML data definition. 最后,我更改了XML数据定义。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM