grafana / iot-sitewise-datasource

IoT Sitewise
Apache License 2.0
18 stars 9 forks source link

Fix: Infer data type for disassociated streams for property value queries by alias #275

Closed kevinwcyu closed 8 months ago

kevinwcyu commented 8 months ago

What this PR does / why we need it:

We currently can't fetch the data type for disassociated data streams. This is because the describe asset property API doesn't support querying by alias, instead it requires an asset id and property id. See the following code where the DataType is set to "?"

https://github.com/grafana/iot-sitewise-datasource/blob/ef82f351fab5cd8c08c3682e348d4c834aa0f34a/pkg/resource/sitewise.go#L30-L45

Since we don't know the data type, when we're building up the frame, we were incorrectly inferring the data type to be a float64 (which is what we infer a field's value type to be by default)

https://github.com/grafana/iot-sitewise-datasource/blob/ef82f351fab5cd8c08c3682e348d4c834aa0f34a/pkg/framer/fields/util.go#L8-L19

This PR uses an existing utility function to infer the correct data type before we start building up the frame. This existing utility function is already used by other query types, e.g. property value history, that's why those ones were not erroring.

Which issue(s) this PR fixes:

Fixes #270

Special notes for your reviewer:

To test: