简体   繁体   中英

How to parse array of struct when creating stream in KSQL

I'm trying to access a key called session ID, here is what the JSON of my message looks like:

{
   "events":[
      {
         "data":{
            "session_id":"-8479590123628083695"}}]}

This is my KSQL code to create the stream,

CREATE STREAM stream_test(
  
  events ARRAY< data STRUCT< session_id varchar> >
  
) WITH (KAFKA_TOPIC='my_topic', 
        VALUE_FORMAT='JSON')

But I get this error,

KSQLError: ("line 4:22: mismatched input 'STRUCT' expecting {'(', 'ARRAY', '>'}", 40001, None)

Does anyone know how to unpack this kind of structure? I'm struggling to find examples

My solution:

  events ARRAY< STRUCT<data STRUCT< session_id varchar >> >

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM