Your hierarchy does not specify how the other levels relate to the "year" level. Adding a level map from month to year should resolve this problem:
+measure:config:levelMap["month", "year"] = "hierarchy:calendar:month2year"
Pergunta
I'm trying to use the measure service in my LogicBlox project. The hierarchy I'm trying to expose is simple:
day(d), day_id(d:i) -> string(i).
week(w), week_id(w:i) -> string(i).
month(m), month_id(m:i) -> string(i).
year(y), year_id(y:i) -> string(i).
day2month[d] = m -> day(d), month(m).
All these predicates live in the hierarchy:calendar
namespace. To add the measure service meta data, I now have the following in a .logic file that I set to “execute” in the project file:
+measure:config:enable().
// Calendar dimension
+measure:config:dimension(_) {
+measure:config:dimension_hasName[]="Calendar",
+measure:config:dimension_hasDefaultHierarchy[]="Default"
}.
// hierarchy default in calendar dimension
+measure:config:hierarchy_byDimName["Calendar", "Default"] = calHier,
+measure:config:hierarchy(calHier) {
+measure:config:level["day"] = "hierarchy:calendar:day",
+measure:config:attribute["day","id","STRING"]="hierarchy:calendar:day_id",
+measure:config:level["month"] = "hierarchy:calendar:month",
+measure:config:attribute["month","id","STRING"]="hierarchy:calendar:month_id",
+measure:config:level["year"] = "hierarchy:calendar:year",
+measure:config:attribute["year","id","STRING"]="hierarchy:calendar:year_id",
+measure:config:levelMap["day", "month"] = "hierarchy:calendar:day2month"
}.
When I compile and deploy this to a workspace, I get the following error:
Error: measure:schema (line 227, column 5): Functional dependency violation: hier=[0], #V0=0, level=[2]. Occurred in logic clause:
+measure:schema:hierarchy_levelAtIndex[hier, 0] = level [fundepcheck] <-
+measure:schema:hierarchy_hasLevel(hier, level),
!$measure_schema:_projection_t_YHtD752_Dm7(hier, level).
What am I doing wrong and/or how do I debug this?
Solução
Your hierarchy does not specify how the other levels relate to the "year" level. Adding a level map from month to year should resolve this problem:
+measure:config:levelMap["month", "year"] = "hierarchy:calendar:month2year"