Can I normalize string field?

#1

Can I normalize a string field using the previous treatment like in the following example?

entity type EdgeMeasurement mixes TimedDataPoint ...... {
    start: datetime
    
    @ts(treatment="PREVIOUS")
    class: string
}
Earliest() on string field
#2

I’m not sure about whether or not that would work, but for a use case like this I’ve usually seen a type that mixes in TimedCharacteristicHistory being used:

entity type EdgeMeasurement mixes TimedCharacteristicHistory<SomeParentType> schema name 'IDK' {
  class: string
}

#3

You can map string values to corresponding enum values (as integers) and normalization can happen based on those enum values

e.g. Provide a valueMapping in the @ts field

entity type AccountStatus mixes TimedDataPoint<AccountStatusSet> schema name 'NORMTEST_ACTSTAT' {

  @ts(treatment='rate', valueMapping='AccountStatusValueMapping')
  status: string enum('active', 'inactive', 'closed')
}

And store the valueMappings in the type as follows:

entity type AccountStatusValueMapping extends TimeseriesValueMapping type key 'ASVM'

Data for the above type can be something like:

{
  "type": "AccountStatusValueMapping",
  "data": [{
    "id": "active", "value": 1
  }, {
    "id": "inactive", "value": 2
  }, {
    "id": "closed", "value": 3
  }]
}
6 Likes
Passing statusCode through custom normalization
#4

@rohit.sureka,
Can you please confirm what a metric would look like against the AccountStatus.status field? Will a metric with expression "max(max(normalized.data.status))" automatically track against the integers mapped?

Thanks,

#5

@rohit.sureka,
Additionally, is the AccountStatusValueMapping required to be aware of all possible enumerated values? Are mappings case-sensitive? What would happen if a status of "in-review" got loaded, but there was no mapping for the status?