Kafka uses a key-value-pair data model. Key and value are independent
from each other.

Thus, you cannot define a single column (ie, single STRUCT) that spans
over key and value, because each column must either be mapped into the
key or the value of the underlying key-value-pair.

So in your example, you define a STRUCT `structure` and thus `structure`
is a column that lives either in the key or the value.

Why do you want/need to define a STRUCT that spans over key and value?


-Matthias




On 9/7/21 10:37 AM, Greer, Andrew C wrote:
> Hello all,
> 
> 
> I was wondering if it is possible to add the message key value to a structure 
> in KSQL. My coworker has a specific need where the key values of the messages 
> should be in the same structure as the other values he is collecting.
> 
> 
> We were hoping something like this would work, but it will not accept that as 
> a value:
> CREATE STREAM PI_STREAM_01 ("Structure" STRUCT<"keyValue" VARCHAR KEY, 
> "Value" VARCHAR>) WITH (KAFKA_TOPIC='lift_twelve', VALUE_FORMAT='KAFKA');
> 
> 
> Thank you,
> 
> Andrew Greer
> 
> 

Reply via email to