Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to plot grouped values when using ARRAY JOIN #326

Closed
KryptosKid opened this issue Feb 20, 2021 · 2 comments · Fixed by #399
Closed

Unable to plot grouped values when using ARRAY JOIN #326

KryptosKid opened this issue Feb 20, 2021 · 2 comments · Fixed by #399
Assignees

Comments

@KryptosKid
Copy link

KryptosKid commented Feb 20, 2021

It appears that the plugin does not properly group results when using ARRAY JOIN with GROUP BY in a query.

Using the following query from grafana, I would expect the graph to plot the separate (key, value) pairs by time:

select
    toUInt32(time) * 1000 as t,
    dataMap.key as key,
    sum(dataMap.value) as value
from test.nested_array_join_example
array join dataMap
group by t, key
order by t, key

Instead, the graph does not plot them appropriately:

image

The example above can be tested with the following:

create database if not exists test;
create table if not exists test.nested_array_join_example
(
    time DateTime,
    dataMap Nested (
        key String,
        value UInt64
    )
)
engine = MergeTree
partition by (toYYYYMMDD(time))
order by (time);

insert into test.nested_array_join_example values
(1613710800, ['a', 'b'], [1, 2]),
(1613710800, ['a', 'b'], [3, 4]),
(1613710801, ['a', 'b'], [5, 6]),
(1613710801, ['a', 'b'], [7, 8]),
(1613710802, ['a', 'b'], [9, 10]);

Versions

Grafana v7.4.1 (07649d1313)
vertamedia-clickhouse-datasource 2.2.3
Clickhouse 21.2.2 revision 54447
@peterpoetzi
Copy link

I have the same problem and solved it by using a VIEW on the server, which returns an identical result set. The problem appears to be the JOIN keyword, when it is present in the query, the function is disabled.

@Slach Slach self-assigned this Dec 21, 2021
@Slach
Copy link
Collaborator

Slach commented Dec 22, 2021

@peterpoetzi @KryptosKid sorry for late reply

I would like to recommends
change query to

$columns(
    dataMap.key AS key,
    sum(dataMap.value) AS value
)
FROM default.nested_array_join_example
ARRAY JOIN dataMap
WHERE $timeFilter

@Slach Slach mentioned this issue Dec 22, 2021
Slach added a commit to Altinity/grafana-plugin-repository that referenced this issue Dec 22, 2021
# 2.4.1 (2021-12-20)

## Enhancements:
* update dependencies, try to fix critical nodejs dependencies issues

## Fixes:
* fix unnecessary warning Logging message on backend part
* fix Altinity/clickhouse-grafana#366
* fix Altinity/clickhouse-grafana#357
* fix Altinity/clickhouse-grafana#345
* fix Altinity/clickhouse-grafana#342
* fix Altinity/clickhouse-grafana#385
* fix Altinity/clickhouse-grafana#317
* fix Altinity/clickhouse-grafana#336
* fix Altinity/clickhouse-grafana#320
* fix Altinity/clickhouse-grafana#326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants