Traversing types with TimeseriesDataPoint

#1

During the Coursera, I encountered an issue while fetching time series data with a filter on the SmartBulb’s id.

Let’s say that I have a base type SmartBulb and data points that I organize as time series.
My types are then defined like this:
entity type SmartBulbMeasurement mixes TimeseriesDataPoint<SmartBulbMeasurementSeries>

which holds the values of the data points, and:

entity type SmartBulbMeasurementSeries mixes TimeseriesHeader<SmartBulbMeasurement> { smartBulb: SmartBulb }

that holds the object “time series” and links it to the SmartBulb instance.

I want to fetch the data points related to the SmartBulb whose id is “SMBLB1”. I tried to do a fetch with the following filter:
parent.smartBulb == "SMBLB1"

but it returns an empty result.
To get the result, I have to filter on parent only with parent == 'SMBS_serialNo_SMBLB1' (but it works only because during data load, we used the SmartBuld id to generate the id of the SmartBulbMeasurementSeries…)

Does someone know why I can’t traverse the relations between the types to filter in that particular case?

0 Likes

#2

TimeseriesDataPoint is a cassandra type, you need a parent key to filter your points otherwise you hit this error:

but you can combine filters: parent == 'SMBS_serialNo_SMBLB1' && somefield==somevalue

0 Likes

#3

@CamilleM To @bachr’s point, the time series data point are stored in cassandra and are stored as a key-value pair (think of it like a hash map). In order for us to look up the value in a hash map, we have to look up by its key, in this case it happens to be the id of the parent a.k.a SmartBuldMeasurementSeries.

So we mandate providing a filter by parent.id & as bachir mentioned, once you have the parent filter, you can filter by any other field too.

1 Like