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

Clickhouse plugin crashes query when using adhoc filters #421

Closed
Nikolina697 opened this issue May 4, 2022 · 0 comments
Closed

Clickhouse plugin crashes query when using adhoc filters #421

Nikolina697 opened this issue May 4, 2022 · 0 comments
Assignees
Milestone

Comments

@Nikolina697
Copy link
Contributor

I use this query:

WITH topx as(select DISTINCT(case when $split :: text = '' then 'other'::text else $split::text end)::text as filter, count() as cnt from $table where $timeFilter and $adhoc group by $split order by cnt desc limit 10)

SELECT
    $timeSeries as t,
    case when $split :: text in (select filter from topx) then $split::text else 'other' end :: text as spl,
    count()
FROM $table data
WHERE
    $timeFilter
    and $adhoc
GROUP BY  spl, t
ORDER BY  spl, t 

It works fine until I apply an adhoc filter, then it becomes malformed and the plugin that uses that filter crashes.
After I applied adhoc filter query looks like this:

WITH topx as(select DISTINCT(case when place : : text = '' then 'other' : : text else place : : text end) : : text as filter, count() as cnt from database_name.table_name where referencetime >= toDateTime(1651034567) AND referencetime <= toDateTime(1651045367) and (number = 20 ) group by place order by cnt desc limit 10)
SELECT
    (intDiv(toUInt32(referencetime), 300) * 300) * 1000 as t,
    case when place : : text in (
    SELECT filter


    FROM topx
),
    then place : : text else 'other' end : : text as spl,
    count()
FROM database_name.table_name data


WHERE
    referencetime >= toDateTime(1651034567) AND referencetime <= toDateTime(1651045367)
    and  (number = 20)
GROUP BY
    spl,
    t
ORDER BY
    spl,
    t

It seems that after the adhoc filter is applied the query becomes malformed, but also if I press Reformat Query without the applied adhoc filter the query is incorrectly formed.

Two issues:

  1. all :: are replaced with : : - the space between the colons
  2. there is an additional comma after the FROM topx) , then place ... which also breaks the query
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

No branches or pull requests

2 participants