Clickhouse: Expose Kafka message's key and topic via virtual columns in tables with Kafka engines

Created on 15 May 2019  Â·  4Comments  Â·  Source: ClickHouse/ClickHouse

The column for key should be named as _key - if the name is taken by user, then we add the number suffix until we get unused column name: e.g. _key1, _key2, etc.
The column for topic should be named as _topic and uses the same number-suffix logic.

If the Kafka message contains multiple rows, then virtual values are the same for all these rows.

Both virtual columns have type String.

Syntax example:

CREATE TABLE kafka (a UInt8, b String) ENGINE Kafka() SETTINGS …;
SELECT a, b, _topic, _key FROM kafka LIMIT 1;
comp-kafka feature st-in-progress

Most helpful comment

Please do not forget _timestamp

All 4 comments

Maybe also partition and offset?

Please do not forget _timestamp

topic, offset, key columns are available in v19.11+

Resolved in v19.14+

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igor-sh8 picture igor-sh8  Â·  3Comments

lttPo picture lttPo  Â·  3Comments

bseng picture bseng  Â·  3Comments

atk91 picture atk91  Â·  3Comments

jimmykuo picture jimmykuo  Â·  3Comments