sqlfluff icon indicating copy to clipboard operation
sqlfluff copied to clipboard

Parse Clickhouse quantiles function

Open lmasikl opened this issue 1 year ago • 2 comments

Search before asking

  • [X] I searched the issues and found no similar issues.

Description

I expect that this query are correct

SELECT quantiles(0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99, 0.999)(click) AS quantiles_click_size
FROM clickhouse_table

but I receive error

sqlfluff lint query.sql --dialect clickhouse
== [query.sql] FAIL                                                                                                                                             
L:   1 | P:  75 |  PRS | Line 1, Position 75: Found unparsable section: '(click)
                       | AS quantiles_click_size'
WARNING: Parsing errors found and dialect is set to 'clickhouse'. Have you configured your dialect correctly?

My configuration

[sqlfluff]
verbose = 0
max_line_length = 88

[sqlfluff:rules:capitalisation.functions]
extended_capitalisation_policy = upper
ignore_words = multiIf,match,quantiles,countIf,uniqExact

Use case

No response

Dialect

clickhouse

Are you willing to work on and submit a PR to address the issue?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

lmasikl avatar Dec 05 '24 12:12 lmasikl

It seems the quantiles function isn't being correctly parsed in the ClickHouse dialect. Consider checking if the dialect configuration supports the specific function syntax or if updates to the dialect are required to handle nested function calls like this.

ghost avatar Dec 07 '24 04:12 ghost

It seems the quantiles function isn't being correctly parsed in the ClickHouse dialect. Consider checking if the dialect configuration supports the specific function syntax or if updates to the dialect are required to handle nested function calls like this.

where would I check that? I cannot see the functions neither in dialect_clickhouse.py not dialect_clickhouse_keywords.py, we encountered a very similar problem with the multiIf function.

babaMar avatar Apr 11 '25 15:04 babaMar

I opened a PR to fix this issue: https://github.com/sqlfluff/sqlfluff/pull/7205

franloza avatar Oct 21 '25 17:10 franloza