grafana / google-bigquery-datasource

Google BigQuery Datasource Plugin for Grafana.
Apache License 2.0
26 stars 13 forks source link

Add "Between time range"($timeFilter) operator to filtering datetime fields #139

Open gelicia opened 2 years ago

gelicia commented 2 years ago

When filtering a datetime field, it would be excellent to have a dropdown selection that would tie a field to the date range picker in the Grafana UI to filter dates that happen within the time range. You can currently do this writing SQL, but many prefer to use the GUI to build queries.

I made an attempt on this but should really get back to my own work šŸ˜… . To save any future devs some time, the merge with my attempt is here (I couldn't get grafana to pick up the update) https://github.com/grafana/google-bigquery-datasource/commit/779f96ffeaa635dfdec29d1eef8f789ce3619b86

The base we use for these operators is https://github.com/ukrbublik/react-awesome-query-builder/blob/master/modules/config/basic.js . Operators get set to a certain type of field here https://github.com/ukrbublik/react-awesome-query-builder/blob/master/modules/config/basic.js#L1060

You can see how we add in custom operators to Grafana here https://github.com/grafana/grafana/blob/main/public/app/features/plugins/sql/components/visual-query-builder/AwesomeQueryBuilder.tsx#L237 It was unclear to me how the two configurations work together.

I am not positive if the part that subs in __timeFilter with actual dates/sql happens after this or not. If it doesn't, this will not work.

zoltanbedi commented 8 months ago

This was added to mysql and postgres https://github.com/grafana/grafana/pull/74575 it is just a matter of copying that code to here as well or refactoring this to use a common component from a shared library.