【发布时间】:2014-08-27 19:30:37
【问题描述】:
假设我们有一个事实表“bi_slots”,其中有字段 (id,region_id,city_id)。其实还有更多的领域,只是这里不感兴趣。
还有 'regions' 表,其中有 (id,name) 字段和 'cities' 表,其中有 (id,name,region_id) 字段。
我需要为“bi_slots”的多维数据集创建一个维度,其中应用的是 Region->Сity 层次结构。而且,我需要从他们各自的表格中获取地区和城市名称。
所以,Dimension 看起来像:
<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>
以及具有此尺寸用途的 Cube 的声明
<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"/>
像这样放置,这使得 Mondrian 根本不显示这个立方体,但是当我从我的维度中删除 CityLevel 时,我得到了一个非常精细的区域过滤。
我们非常欢迎任何帮助,我们真的没有想法。
【问题讨论】:
-
您想在 Cube View 中使用 SQL 实现什么?当有非常复杂的数据时,我可能会使用它两次?你真的可以简化从雪花模式到星型模式的事情吗?在 ETL 过程中制作表地址(ID、City_Name、ID_Region、Region_Name)。将 Region 作为顶层。多维数据集设置有问题时,Saiku 不显示多维数据集,您可以查看日志文件,或尝试在 Pentaho Schema Workbench 中修改 xml。
-
SQL 在视图中是微不足道的,对另一个维度的简单转换,只关心创建日期,而不关心日期和时间。所以最好的做法是创建一个辅助表?
-
Snowflake 在以下几种情况下很有用:当您无法构建 StarSchema 时,当存在 meny:many 关系时,当您的维度是高基数时。在您的情况下,最好阅读日志文件并检查:mondrian.pentaho.com/documentation/schema.php#Star_schemas
-
谢谢!然后是星型模式。