Doris: GROUP_CONCAT(DISTINCT x, sep) is written back with an extra ',' argument

Open Beginner friendly
#9,475 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sql
Domain
databases

Research direction

Start by tracing how SQLGlot parses and writes GROUP_CONCAT(DISTINCT x, '|') for the Doris dialect, then inspect nearby Doris dialect tests for GROUP_CONCAT cases. Add a regression case for the reported input and verify Doris output contains only the value and separator arguments; the issue's expected SQL provides the completion check.

Written by the indexing model from the issue text.

Description

The Doris dialect adds a third argument when it writes GROUP_CONCAT(DISTINCT x, sep) back:

import sqlglot

sqlglot.transpile("SELECT GROUP_CONCAT(DISTINCT x, '|') FROM t", read="doris", write="doris")
# ["SELECT GROUP_CONCAT(DISTINCT x, '|', ',') FROM t"]

Expected: SELECT GROUP_CONCAT(DISTINCT x, '|') FROM t.

Doris rejects the output: GROUP_CONCAT(DISTINCT x, '|', ',') fails with multi_distinct_group_concat requires one or two parameters. The input runs: SELECT GROUP_CONCAT(DISTINCT x, '|') FROM (SELECT 'a' AS x UNION ALL SELECT 'b' UNION ALL SELECT 'a') t returns a|b.

It looks like the separator is read as a second DISTINCT operand, and the default ',' separator is then appended.

Docs: https://doris.apache.org/docs/sql-manual/sql-functions/aggregate-functions/group-concat

Checked on main (c321d9f). I used an LLM (Claude) to help narrow this down and write it up; I checked the reproductions against SQLGlot and Doris myself.

Dominant language
Python
Stars
9.8k
Forks
1.5k
Avg merge
10h 54m
Merged PRs (30d)
310

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tobymao/sqlglot

All issues in tobymao/sqlglot

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.