ClickHouse / ClickHouse/ClickHouse

WITH FILL … INTERPOLATE is lost inside subquery/CTE when analyzer is enabled

Open
#86,151 2 comments 0 reactions 0 assignees View on GitHub
bug comp-query-analyzer external
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

### Describe what's wrong

When ORDER BY … WITH FILL … INTERPOLATE appears inside a subquery or CTE, the filled rows disappear in the outer query. Running the same SELECT at the top level (no nesting) correctly returns the interpolated rows. Disabling the new analyzer (enable_analyzer=0) restores the expected results.

Repro Fiddle: https://fiddle.clickhouse.com/1d7a5b7c-5eef-4b0e-bf5b-ec46711da550

### Does it reproduce on the most recent release?

Yes

### How to reproduce

### 1) Top-level query (works)

```sql
SELECT *
FROM (
SELECT now() - INTERVAL 3 DAY AS ts, 99 AS v
)
ORDER BY 1
WITH FILL
TO now()
STEP toIntervalDay(1)
INTERPOLATE
```

**Observed**: returns a filled day-by-day timeline from `ts` to `now()` (multiple rows, one per day).

### 2) Nested once (broken)

```sql
SELECT *
FROM (
SELECT *
FROM (
SELECT now() - INTERVAL 3 DAY AS ts, 99 AS v
)
ORDER BY 1
WITH FILL
TO now()
STEP toIntervalDay(1)
INTERPOLATE
)
```

**Observed**: returns **only the original row**, i.e., no filled rows survive the outer query.

### 3) CTE form (broken)

```sql
WITH test AS (
SELECT *
FROM (
SELECT now() - INTERVAL 3 DAY AS ts, 99 AS v
)
ORDER BY 1
WITH FILL
TO now()
STEP toIntervalDay(1)
INTERPOLATE
)
SELECT * FROM test;
```

**Observed**: same as (2) — no filled rows preserved.

### Expected behavior

Queries (2) and (3) should return the same filled/interpolated result as (1). Nesting should not eliminate the effect of `WITH FILL … INTERPOLATE`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.