Hi all, when working with Mondrian I encounter a strange problem this morning:
- I create a Time dimension that have data from 2001 to 2020: D_PRD. Config in xml file:
- I create a fact table that have 2 dimension, one is Time dimension: F_FACT_TABLE
- I create an aggregate table that only have Time dimension at Day level: AGG_01_F_FACT_TABLE
- I create another aggregate table that only have Time dimension at Month level: AGG_02_F_FACT_TABLE
Because I add condition to the dimension configuration, Mondrian never use the second aggregate table AGG_02_F_FACT_TABLE. Below is 2 SQL for when I add condition (SQL 1) and then remove it (SQL 2)
SQL 1:
SQL 2:
Please help me adding condition to dimension table but can still make good use of aggregate table. Thanks!
- I create a Time dimension that have data from 2001 to 2020: D_PRD. Config in xml file:
Code:
<Dimension name="Day">
<Hierarchy hasAll="true" primaryKey="PRD_ID">
<Table name="D_PRD" schema="MONDRIAN_TEST">
<SQL dialect="generic">
<=!=[=C=D=A=T=A=[ (
D_PRD.prd_id >= 20120101 and D_PRD.prd_id < 20140101]=]=>
</SQL>
</Table>
<Level name="Year" column="YEAR" type="Numeric" uniqueMembers="false">
</Level>
<Level name="Month" column="MONTH_NAME" type="String" uniqueMembers="false">
</Level>
<Level name="Day" column="PRD_ID" type="Numeric" uniqueMembers="false">
</Level>
</Hierarchy>
</Dimension>
- I create an aggregate table that only have Time dimension at Day level: AGG_01_F_FACT_TABLE
- I create another aggregate table that only have Time dimension at Month level: AGG_02_F_FACT_TABLE
Because I add condition to the dimension configuration, Mondrian never use the second aggregate table AGG_02_F_FACT_TABLE. Below is 2 SQL for when I add condition (SQL 1) and then remove it (SQL 2)
SQL 1:
Code:
select
"D_PRD"."YEAR" as "c1",
"D_PRD"."MONTH" as "c2",
sum("AGG_01_F_FACT_TABLE"."T_ORG_COST") as "m0",
sum("AGG_01_F_FACT_TABLE"."T_PROM_COST") as "m1",
sum("AGG_01_F_FACT_TABLE"."T_TOT_COST") as "m2"
from
"MONDRIAN_TEST"."AGG_01_F_FACT_TABLE" "AGG_01_F_FACT_TABLE",
"MONDRIAN_TEST"."D_PRD" "D_PRD"
where
"AGG_01_F_FACT_TABLE"."PRD_ID" = "D_PRD"."PRD_ID"
and
(D_PRD.prd_id >= 20120101 and D_PRD.prd_id < 20140101)
and
"AGG_03_THANGLD_MONDRIAN"."PRD_ID" = "D_PRD"."PRD_ID"
and
"D_PRD"."YEAR" = 2013
group by
"D_PRD"."YEAR",
"D_PRD"."MONTH"
Code:
select "AGG_02_F_FACT_TABLE"."YEAR" as "c1",
"AGG_02_F_FACT_TABLE"."MONTH" as "c2",
sum("AGG_02_F_FACT_TABLE"."T_ORG_COST") as "m0",
sum("AGG_02_F_FACT_TABLE"."T_PROM_COST") as "m1",
sum("AGG_02_F_FACT_TABLE"."T_TOT_COST") as "m2"
from
"MONDRIAN_TEST"."AGG_02_F_FACT_TABLE" "AGG_02_F_FACT_TABLE",
where
"AGG_02_F_FACT_TABLE"."YEAR" = 2013
group by
"AGG_02_F_FACT_TABLE"."YEAR",
"AGG_02_F_FACT_TABLE"."MONTH"