Skip to content

[FORMATTING] ClickHouse: aggregate functions with combinators (countMerge, sumIf, ...) get a space before the parenthesis #990

Closed as not planned

Description

@MunMunMiao

Input data

SELECT sumIf(x, y > 1), countMerge(s), uniqExactIfState(id), groupArrayArray(a) FROM t

Options: { language: 'clickhouse' }

Expected Output

SELECT
  sumIf(x, y > 1),
  countMerge(s),
  uniqExactIfState(id),
  groupArrayArray(a)
FROM
  t

Actual Output

SELECT
  sumIf (x, y > 1),
  countMerge (s),
  uniqExactIfState (id),
  groupArrayArray (a)
FROM
  t

Usage

  • format(sql, { language: 'clickhouse' })
  • ClickHouse. The function list of the dialect comes from system.functions, which does not contain the names ClickHouse builds from an aggregate function and a combinator (-If, -State, -Merge, ...). They are treated as identifiers, so they get a space before the parenthesis, unlike sum(x). They are common in materialized views and queries on AggregatingMergeTree tables.
  • sql-formatter 15.9.0

A fix is in #988.


This was prepared with Claude Code (an AI coding assistant); the outputs above come from sql-formatter 15.9.0.

Activity

  1. MunMunMiao commented on Oct 14, 2026

    @MunMunMiao
    Author

    Closing for now: I'm going to handle the formatting on my side instead. Thanks for the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions