我试图在Mondrian模式中定义时间维度。在蒙德里安时间维度中,它要求3级类型必须是YearsQuartersMonths
但我的表只包含一个日期字段。那怎么可能呢?
我可以在Mondrian中使用postgreSQL查询吗?因此,我可以使用3个查询从单个日期字段中选择YearsQuartersMonth

最佳答案

创建只有一个日期列的简单表:

create table tmp_cube as (select generate_series('2011-01-01'::date, '2012-01-01'::date, '1 day')::date gs);

创建虚拟多维数据集:
<Schema name="New Schema1">
  <Cube name="Test" visible="true" cache="true" enabled="true">
    <Table name="tmp_cube" schema="public" alias="">
    </Table>
    <Dimension type="TimeDimension" visible="true" foreignKey="gs" name="Time Dimension">
      <Hierarchy name="New Hierarchy 0" visible="true" hasAll="true" primaryKey="gs">
        <View alias="test_view">
          <SQL dialect="generic">SELECT gs, extract(year from gs) as year, extract(quarter from gs) as quarter, extract(month from gs) as month FROM tmp_cube</SQL>
        </View>
      <Level name="Year" visible="true" column="year" type="Integer" internalType="int" uniqueMembers="false" levelType="TimeYears">
        </Level>
        <Level name="Quarter" visible="true" column="quarter" type="Integer" uniqueMembers="false" levelType="TimeQuarters">
        </Level>
        <Level name="Month" visible="true" column="month" type="Integer" uniqueMembers="false" levelType="TimeMonths">
        </Level>
      </Hierarchy>
    </Dimension>
    <Measure name="Count Rows" column="gs" aggregator="count" visible="true">
    </Measure>
  </Cube>
</Schema>

现在我在赛库看到:

关于postgresql - 在Mondrian模式中定义时间维度?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21933424/

10-10 14:16