Skip to content

Conversation

@hermanschaaf
Copy link
Contributor

Though not explicitly documented, in practice, ClickHouse supports multiple consecutive ARRAY JOIN statements, such as:

SELECT
    v,
    j
FROM t1
    ARRAY JOIN JSONExtractArrayRaw(a) AS j
    ARRAY JOIN array(
    JSONExtractString(j, 'x'),
    JSONExtractString(j, 'y')
) AS v;

Before this change, such queries failed parsing, as there was an assumption of only a single ARRAY JOIN statement in the parser logic. This change adds a test for this case and modifies the code to allow multiple ARRAY JOIN statements.

Example

Here is a minimal reproduction that can be tested on a ClickHouse server vs the ClickHouse SQL Parser:

CREATE TABLE t1
(
    a String
)
ENGINE = Memory;

INSERT INTO t1 VALUES
('[{"x":"1","y":"2"}]');

SELECT
    v,
    j
FROM t1
ARRAY JOIN JSONExtractArrayRaw(a) AS j
ARRAY JOIN array(
    JSONExtractString(j, 'x'),
    JSONExtractString(j, 'y')
) AS v;

@coveralls
Copy link

Pull Request Test Coverage Report for Build 21181160987

Details

  • 14 of 22 (63.64%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.006%) to 51.201%

Changes Missing Coverage Covered Lines Changed/Added Lines %
parser/parser_query.go 8 10 80.0%
parser/walk.go 2 4 50.0%
parser/ast.go 4 8 50.0%
Totals Coverage Status
Change from base Build 21066744130: 0.006%
Covered Lines: 8017
Relevant Lines: 15658

💛 - Coveralls

@git-hulk git-hulk merged commit 264c312 into AfterShip:master Jan 21, 2026
1 check passed
@git-hulk
Copy link
Member

@hermanschaaf Thanks for your great fix.

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 this pull request may close these issues.

3 participants