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;
Maybe also partition and offset?
Please do not forget _timestamp
topic, offset, key columns are available in v19.11+
Resolved in v19.14+
Most helpful comment
Please do not forget _timestamp