ClickHouse / ClickHouse/ClickHouse

Allow to erase source of MATERIALIZED key column

Open
#109,371 1 comment 0 reactions 0 assignees View on GitHub
comp-mutations external feature
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

### Company or project name

_No response_

### Use case

For now if
- a source column A has MATERIALIZED column B related to it
- and column B is used in index
then column A cannot be ALTERED to NULL/default to free space

I.e. we have only one source JSON column in INSERTs. Then we extract many columns from the JSON and ALTER it to free space just after insertion. It's not possible for now if we use extracted fields in PK.

### Describe the solution you'd like

Add `MATERIALIZED [ONCE]` modifier to break any logical relation between source and materialized columns after insertion.

It not a case of `EPHEMERAL` column cause we could want a source JSON to live in column for some time. I.e. keep a last day of data in RAW format and only extracted fields after that.

As alternative there could be an intermediate `EPHEMERAL` column E with two `MATERIALIZED` directions - to A and to B. I haven't check if it possible for key columns yet. But it looks more complicated to have additional `EPHEMERAL` column just to materialize keys.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

The issue names no files, tests, or entry points. Start by tracing ClickHouse handling for MATERIALIZED columns and key-column dependency checks, using the JSON source and extracted-key scenario as the reproduction. Done means a MATERIALIZED [ONCE] option permits the source column to be altered after insertion without breaking the materialized key column.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.