我的JSON中的一个字段名称是“ User-Agent”。当我尝试使用该字段名称创建流时,KSQL不喜欢破折号。我已经尝试过用单引号,双引号将其转义,但不走运。
我如何从主题中的json中获取该字段以包含在KSQL流中?
以下是我的一些尝试的记录:
ksql> create stream tmpstream (startTimeEpoch bigint, type VARCHAR, src VARCHAR, 'user-agent' varchar) with (KAFKA_TOPIC='foo', VALUE_FORMAT='JSON');
line 1:76: extraneous input ''user-agent'' expecting {'ADD', ...}
ksql> create stream tmpstream (startTimeEpoch bigint, type VARCHAR, src VARCHAR, user-agent varchar) with (KAFKA_TOPIC='foo', VALUE_FORMAT='JSON');
line 1:80: extraneous input '-' expecting {'ADD', ...}
ksql> create stream tmpstream (startTimeEpoch bigint, type VARCHAR, src VARCHAR, "user-agent" varchar) with (KAFKA_TOPIC='foo', VALUE_FORMAT='JSON');
Message
----------------
Stream created
----------------
ksql> select * from tmpstream;
Code generation failed for SelectValueMapper
Caused by: Line 1, Column 15: Expression "TMPSTREAM_user" is not an rvalue
ksql> drop stream tmpstream;
Message
--------------------------------
Source TMPSTREAM was dropped.
--------------------------------
ksql> create stream tmpstream (startTimeEpoch bigint, type VARCHAR, src VARCHAR, "user\-agent" varchar) with (KAFKA_TOPIC='foo', VALUE_FORMAT='JSON');
Message
----------------
Stream created
----------------
ksql> select * from tmpstream;
Code generation failed for SelectValueMapper
Caused by: Line 1, Column 15: Expression "TMPSTREAM_user" is not an rvalue