Typorithm · medium

arrayJoin

array-joinclickhousearraysunfold
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn arrayJoin

0%

Querying

ClickHouse stores arrays in columns; arrayJoin(col) (or ARRAY JOIN) unfolds an array into one output row per element, repeating the other columns.

ClickHouse can store arrays directly in a column, so a single event row may carry many tags.

arrayJoin(col) unfolds that array, emitting one row per element while repeating the row's scalar columns.

The ARRAY JOIN clause does the same in the FROM section and is preferred when joining multiple arrays together.

01

Arrays live inside a single column.

02

arrayJoin(col) = one row per element.

03

Scalar columns repeat across the rows.

SELECT
    user_id,
    arrayJoin(tags) AS tag
FROM events;

Read the implementation

Connect each part of the code to the concept before you type.

1. Unfold the array

arrayJoin() expands an array column into one row per element.

arrayJoin(tags) AS tag

2. Kept column

Scalar columns like user_id are repeated for each unfolded element.

user_id

3. Array source

The events table holds an array column, tags, per row.

FROM events

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

arrayJoin: Lesson & Practice · Typorithm | ApplyDjinn