2014-08-27 51 views
1

假設我們有一個事實表「bi_slots」,其中有字段(id,region_id,city_id)。實際上有更多的領域,但他們在這裏沒有興趣。在Mondrian/Saiku中創建來自不同表格名稱的層次結構

還有'地區'表中有(id,name)字段和'cities'表(id,name,region_id)字段。

我需要的是爲「bi_slots」的多維數據集製作維度,其中應用的是Region->Сity層次結構。而且,我需要從他們各自的表格中抓取地區和城市名稱。

所以,外形尺寸是這樣的:

<Dimension name="AddressDimension" caption="Address"> 
    <Hierarchy name="AddressHierarchy" hasAll="true" primaryKey="id" caption="Region" allMemberCaption="Regions"> 
     <Table name="regions"/> 
     <Level table="regions" column="id" nameColumn="name" name="RegionLevel" uniqueMembers="true" type="String" caption="Region"/> 
     <Level table="cities" column="id" nameColumn="name" name="CityLevel" uniqueMembers="true" type="String" caption="City"/>  
    </Hierarchy> 
</Dimension> 

和會議宣言的立方體與此dimensionUsage

<Cube name="SlotsCube" caption="Slot Cube"> 
    <View alias="bi_slots"> 
    <SQL><![CDATA[ 
     select *, date_trunc('day', created_at) as date_created_at from bi_slots 
    ]]></SQL> 
    </View> 

<DimensionUsage name="AddressDimension" source="AddressDimension" foreignKey="region_id"/> 

被放在這個樣子,這讓蒙德里安不顯示這個立方體可言,但是當我從我的維度中刪除CityLevel,我得到了一個完美的地區過濾。

任何幫助都會比歡迎,我們真的沒有想法在這裏。

+0

想要在多維數據集視圖中使用SQL實現什麼?當有非常複雜的數據時,我可能會使用它兩次?你真的可以簡化從雪花到星型模式的事情嗎?在ETL過程中使表地址(ID,City_Name,ID_Region,Region_Name)。將區域視爲最高級別。當多維數據集設置中出現錯誤時,Saiku不顯示多維數據集,您可以檢出日誌文件,或嘗試在Pentaho Schema Workbench中修改xml。 – fenix 2014-08-27 19:55:20

+0

視圖中的SQL是無關緊要的,是一個只關心創建日期而不關注日期和時間的另一維度的簡單轉換。所以最好的做法是創建一個幫助表? – 2014-08-27 20:47:29

+0

在少數情況下,雪花很有用:當您無法構建StarSchema時,如果存在多方關係,那麼當您的尺寸爲高基數時。在你的情況下,最好閱讀日誌文件並檢查:http://mondrian.pentaho.com/documentation/schema.php#Star_schemas – fenix 2014-08-27 20:56:20

回答

-1

不能像這樣添加來自不同表格的列。

首先,正如在帖子的評論中指出的那樣,您應該使用星型模式。

但是,如果您不能或不想,您可以創建聯接,指定涉及的各種表以及如何聯接。只有在定義它之後,纔可以在同一維度的不同表格中引用列。

請參閱documentation的第4章。