fr-ser / grafana-sqlite-datasource

Grafana Plugin to enable SQLite as a Datasource
Apache License 2.0
124 stars 17 forks source link

Handling of NULL values #11

Closed mi-fel closed 3 years ago

mi-fel commented 3 years ago

Functions LAG and LEAD do not work without non-mandatory parameters [,OFFSET] [,DEFAULT].

"Explore" shows no query results and no errors. Dashboard Builder shows "Metric request error":

Metric request error Object status:500 statusText:"Internal Server Error" data:Object message:"Metric request error" config:Object url:"api/ds/query" method:"POST"

fr-ser commented 3 years ago

This plugin does not alter the SQL at all right now. The only replacement that is done is in the frontend with variables (such as $__to). Therefore it would surprise me very much if the plugin is at fault here. Nevertheless, could you post a query, that is not working in Grafana, but is working locally? And could you give a small seed.sql file so I can have some data to test against?

For debugging and logging it might be good to check the query inspector: https://community.grafana.com/t/using-grafanas-query-inspector-to-troubleshoot-issues/2630

But if the query inspector provides not more information than already provided, the Grafana logs might be helpful as well.

mi-fel commented 3 years ago

You could use any DB, for example this one: https://cdn.sqlitetutorial.net/wp-content/uploads/2018/03/chinook.zip

And this is the query that doesn't work in Grafana:

SELECT  AlbumId, 
LAG(AlbumId) OVER(ORDER BY AlbumId) prev_AlbumId, 
LEAD(AlbumId) OVER(ORDER BY AlbumId) next_AlbumId
FROM albums
limit 5;
fr-ser commented 3 years ago

Thank you very much for the data! The problem does not seem to be the query, but NULL data. I think he plugin does not handle type conversion correctly with NULL values and I will investigate a bit and let you know

fr-ser commented 3 years ago

I updated the plugin and released a new version. @mi-fel could you test this out? https://github.com/fr-ser/grafana-sqlite-datasource/releases/tag/v0.1.3

mi-fel commented 3 years ago

Yes, it works in v0.1.3. Thank you very much!

However, the query result does not contain the NULL values, see a comparison with the SQLite. It would be better to show the NULL values as well. Is it possible in Grafana?

no NULL

fr-ser commented 3 years ago

This is a display setting in Grafana. You can decide how to handle NULL values. You can fill in the string "NULL" for example: image

But since the issue has been solved I will close this now. Thank you very much for finding and reporting a bug!