Showing mysql json_array in a histogram?

I’m a newbie to grafana.
I have a mysql 8.0 datasource where I store some result in a table.
One of the datatypes is list of floats store as a json-type (always array, not object).
Eg:
[0.017488631429, 0.26068300203, 0.07274529954, 0.01087933394, 0.11306773303, 0.22424935174, 0.032254569974, 0.01134010573, 0.19860789179, 0.14142807333, 1.5267597024, 1.3590681816, 1.4012729169, 1.904265782, 1.9979217332, 1.7610441844, 1.9176101905, 2.418887416, 2.3316332515, 2.1566200344]

Is it possible to show/transform these values into a histogram?

After some reading I found the answer myself.

mysql> set @json= '[0.017488631429, 0.26068300203, 0.07274529954, 0.01087933394, 0.11306773303, 0.22424935174, 0.032254569974, 0.01134010573, 0.19860789179, 0.14142807333, 1.5267597024, 1.3590681816, 1.4012729169, 1.904265782, 1.9979217332, 1.7610441844, 1.9176101905, 2.418887416, 2.3316332515, 2.1566200344]';
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT *
    ->      FROM
    ->        JSON_TABLE(
    ->          @json,
    ->          "$[*]"
    ->          COLUMNS(
    ->            Value float PATH "$"
    ->          )
    ->        ) data;
+-----------+
| Value     |
+-----------+
| 0.0174886 |
|  0.260683 |
| 0.0727453 |
| 0.0108793 |
|  0.113068 |
|  0.224249 |
| 0.0322546 |
| 0.0113401 |
|  0.198608 |
|  0.141428 |
|   1.52676 |
|   1.35907 |
|   1.40127 |
|   1.90427 |
|   1.99792 |
|   1.76104 |
|   1.91761 |
|   2.41889 |
|   2.33163 |
|   2.15662 |
+-----------+
20 rows in set (0.00 sec)
2 Likes