pme
pme

Reputation: 14803

How to select the Key of a Record in a Select statement

I created this record:

new ProducerRecord(topic = "petstore-msg-topic", key = msg.username, value = s"${msg.route},${msg.time}")

I want now to do something like this:

CREATE STREAM petstorePages (KEY, route VARCHAR, time VARCHAR) \
                  WITH (KAFKA_TOPIC='petstore-msg-topic', VALUE_FORMAT='DELIMITED');

Is there a possibility to access the key in the Stream creation or do I have to include the key also in the value?

Upvotes: 3

Views: 1385

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191681

It's added automatically and called ROWKEY

KSQL adds the implicit columns ROWTIME and ROWKEY to every stream and table, which represent the corresponding Kafka message timestamp and message key

https://docs.confluent.io/current/ksql/docs/syntax-reference.html#id16

Upvotes: 3

Related Questions