Altinity / clickhouse-grafana

Altinity Grafana datasource plugin for ClickHouse®
MIT License
713 stars 120 forks source link

Ad-hoc filters - error when evaluating varchar field with numeric value #502

Closed afagundes closed 7 months ago

afagundes commented 8 months ago

We discovered a potential problem in the ad-hoc filters where fields of type varchar containing numeric values are assessed as numbers. The values are appended to the final query without quotation marks, resulting in the following error:

Captura de Tela 2023-12-11 às 11 06 59

This particular field is a LowCardinality(String) whose values are something like '1', '1000' or 'C'.

Investigating the source code, I found this line that casts numeric values:

image

when I change the code to treat all values as strings, all filters work as expected.

image

I'm not sure if this is the best approach, since it forces Clickhouse to do the conversion. But in my tests I didn't feel any performance issues.

If it's ok, I'll submit a pull request with the change.

Slach commented 7 months ago

@afagundes =) looks like you located issue in https://github.com/grafana/clickhouse-datasource/, but this is a different plugin, please clarify, do you use Altinity ClickHouse plugin for Grafana or Grafana ClickHouse Datasource?

afagundes commented 7 months ago

Hi @Slach. Apologies, I opened this issue in the wrong project. I'll close it now and open a new one in the correct repository. Thanks!