TSDecl metric using non-foreign key field


#1

I have a type defined as follows:

entity type MyType {
  periods: [TimeRange] schema suffix 'PER'

  self: [MyType] (id, id)
}

We would like to define a metric that simply returns a 1 if the timestamp is within one of the TimeRanges in the periods field. We have tried:

{
  "id": "TimestampWithinPeriod_MyType",
  "name": "TimestampWithinPeriod",
  "srcType": "MyType",
  "path": "self",
  "tsDecl": {
    "data": "periods",
    "start": "start",
    "end": "end",
    "treatment": "COUNT"
  }
}

but don’t get any results trying that. However, if we instead change our data model to:

entity type MyType {
  periods: [MyTimeRangeType] (parent)

  self: [MyType] (id, id)
}
entity type MyTimeRangeType {
  parent: !MyType
}

and use the same metric, everything works as expected. Is this as expected? If so, is there any way to define a TsDecl metric on a field that is not using an fkey relationship but instead a schema suffix?