簡體   English   中英

Pentaho Mondrian使用匯總表

[英]Pentaho Mondrian using aggregate tables

我有Pentaho Mondrian的xml架構描述。 看起來像這樣:

    <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>

我們的時間維度<Dimension foreignKey="dt" name="dt" type="TimeDimension">包含兩個級別:“年”和“月”當我選擇級別“年”時,蒙德里安按年份匯總數據。

看起來不錯,但是表world_steel_production_data在數據中具有兩個動態級別,這些動態級別定義了列dl(1年動態和4月動態)

在此處輸入圖片說明

當我在1980年按年份匯總數據時,這種情況包含具有年份和月份動態的數據。

我已閱讀( http://mondrian.pentaho.com/documentation/aggregate_tables.php),Pentaho可以使用聚合表,並且我想使用它們來拆分我的月份和年份動態。

我已經創建了兩個表來匯總表

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

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

但是,現在我正在徘徊如何在xml模式定義中對Pentaho說:將第一個視圖用於年份動態,將第二個視圖用於月份動態?

或者,也許還有另一種方式可以分解年份和月份的動態?

我想我已經找到了解決方案。 蒙德里安(Mondrian)具有封閉表(Closure table)( http://mondrian.pentaho.com/documentation/schema.php#Closure_tables )之類的東西。 在此表上,您可以定義如何在層次結構維度中進行匯總。

我在這種情況下所做的事情:

  1. 我已經為日期創建並填充了層次結構表,並將該表與架構中的數據表鏈接。

在此處輸入圖片說明

  1. 接下來,我創建並填充了關閉表。

在此處輸入圖片說明

如您所見,由於我的world_steel_production_time_hierarchy根本沒有層次結構(time_id = parent_time_id),因此我已經填寫了關閉表。

  1. 最后,我更改了XML數據定義。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM