v.23.12New Feature

ALIAS Column Reference in Index Definitions Now Supported

It is now possible to refer to ALIAS column in index (non-primary-key) definitions (issue #55650). Example: CREATE TABLE tab(col UInt32, col_alias ALIAS col + 1, INDEX idx (col_alias) TYPE minmax) ENGINE = MergeTree ORDER BY col;. #57546 (Robert Schulze).
It is now possible to use ALIAS columns in index definitions (non-primary-key) in ClickHouse tables.

Why it matters

This feature allows users to create indexes on ALIAS columns directly, solving the limitation where indexes could not reference computed ALIAS columns. It improves flexibility and efficiency in query optimization by enabling indexes on derived data without storing additional columns.

How to use it

Define an ALIAS column in your table schema and then reference this ALIAS column in your index definition. For example:

CREATE TABLE tab(
col UInt32,
col_alias ALIAS col + 1,
INDEX idx (col_alias) TYPE minmax
) ENGINE = MergeTree ORDER BY col;