现在的场景是fact表为t_line_query(记录每条线路被查询的次数),维度表为t_lines(记录所有的线路),t_cities(所有的城市表)
t_line_query外键line_id连接t_lines的主键id,t_lines的外键city_id连接t_cities主键id,整个维度分为3个level:city,lineName,direction
正确的写法如下:
<Table name="t_line_query"/>
<Dimension type="StandardDimension" foreignKey="line_id" name="Lines">
<Hierarchy name="Lines" hasAll="true" allMemberName="All Lines" primaryKey="id" primaryKeyTable="t_lines">
<Join leftKey="city_id" rightAlias="t_cities" rightKey="id">
<Table name="t_lines"/>
<Table name="t_cities"/>
</Join>
<Level name="City" table="t_cities" column="name" type="String" uniqueMembers="true" />
<Level name="lineName" table="t_lines" column="line_name" type="String" uniqueMembers="false" />
<Level name="direction" table="t_lines" column="direction" type="Integer" uniqueMembers="false" />
</Hierarchy>
</Dimension>