meln5674 / grafana-mongodb-community-plugin

Open Source Grafana Plugin for querying MongoDB
GNU Affero General Public License v3.0
137 stars 18 forks source link

Nullable field types do not work #11

Closed filips123 closed 1 year ago

filips123 commented 1 year ago

Prefixing field type with * to annotate a nullable field does not work. I've tested this both with v0.2.0+rc3 and v0.1.2.

This is how a part of a record looks:

screenshot

When I set updated's field type to time, I get this error in Grafana:

Failed to convert document number 0: Failed to extract value columns: Field updated was null or absent, but is not nullable. If using schema inference, please increase the depth to the first document missing this field, or manually specify the schema, map[_id:ObjectID("6414a3a843c8187a3d45a4b5") lat:<nil> lon:<nil> owner_id:111111111 owner_name:filips123 sensors:[map[quantity:CO2 sensor_id:a5ce9e16-0766-43e1-b8bc-81a3e8e9a17a sensor_name:Test CO2 short_id:QF2 unit:kg/m3]] station_id:d6d4b596-4608-46f0-9b0f-675b9e981aa1 station_name:Test token:XXXXXX updated:<nil>]

The same happens when I try to prefix field name with *. When I set the type to *time instead, I this error happens:

Invalid Type: *time
filips123 commented 1 year ago

Actually, I think the problem is that the field was storied as string instead of the date type. This issue is probably invalid, but I think the error messages should still be improved.

meln5674 commented 1 year ago

From the docs linked in the tooltip, the type for native timestamps is time.Time, so the error message is correct *time is not a valid type. If there's a way of phrasing it that you think would be more intuitive, I'd be happy to consider changing it.