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 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
  }]
}

Passing statusCode through custom normalization