Metric has tsDecl.data which is not defined as an fkey field in header type


#1

I’m getting the following error and I’m not sure why… can somebody shed some light on this?

remix type Organization {

  validChildFacilities: [Facility] stored calc "unique(denormChildren.to.facilities.(not(endsWith(id,'#'))))" schema name 'VCF'

}

SimpleMetric:

{
  "id" : "ConnectedFacilites_Organization",
  "name" : "ConnectedFacilities",
  "srcType" : "Organization",
  "tsDecl": {
    "data": "validChildFacilities",
    "treatment": "ROLLINGCOUNT",
    "start": "meta.created",
    "overlapHandling": "SUM"
  },
  "description": "Number of facilities connected to an organization"
}

When evaluating this metric with evalMetricWithMetadata, I get the following error:
“Invalid metric ‘ConnectedFacilites_Organization’: Metric ‘ConnectedFacilities’ with id ‘ConnectedFacilites_Organization’ has tsDecl.data ‘validChildFacilities’ which is not defined as an fkey field in header type ‘Organization’”

Additionally when evaluating with evalMetric I get:
“String index out of range: 0”

Does anybody see something obviously wrong?


#2

@sean.summers In order to promote better design we require the data field to point to an fkey fields which means that the heavy volume (data points) are stored separately rather than on the object itself.

I would expect your type to look somewhat like this:

remix type Organization {
  validChildFacilities: [Facility] (org)
}