ksql流列名中的小写字符使列为空

时间:2019-07-31 09:56:09

标签: apache-kafka confluent ksql

我使用以下方法从现有流post中创建了一个新流post_raw

create stream "post" AS select id AS "ID", id AS "id" FROM post_review

运行SELECT id, "id" FROM post时,我得到:

5ce0a41de36bcb6769fea850 | null
5ce0e44b9f3990676209a901 | null
5ce0e9613ec64f1132918f2a | null
5ce13c599f3990676209a915 | null
5ce1bf9c3ec64f1132918fb9 | null

它接缝,如果列名中有任何小写字符,则ksql使列值null变大。 post的基本主题是获取数据。

print post返回:

{"ROWTIME":1564559632738,"ROWKEY":"5ce0a41de36bcb6769fea850","ID":"5ce0a41de36bcb6769fea850","id":"5ce0a41de36bcb6769fea850"}
{"ROWTIME":1564559634853,"ROWKEY":"5ce0e44b9f3990676209a901","ID":"5ce0e44b9f3990676209a901","id":"5ce0e44b9f3990676209a901"}
{"ROWTIME":1564559636963,"ROWKEY":"5ce0e9613ec64f1132918f2a","ID":"5ce0e9613ec64f1132918f2a","id":"5ce0e9613ec64f1132918f2a"}
{"ROWTIME":1564559643305,"ROWKEY":"5ce13c599f3990676209a915","ID":"5ce13c599f3990676209a915","id":"5ce13c599f3990676209a915"}
{"ROWTIME":1564559643305,"ROWKEY":"5ce1bf9c3ec64f1132918fb9","ID":"5ce1bf9c3ec64f1132918fb9","id":"5ce1bf9c3ec64f1132918fb9"}

为什么ksql将小写的列值设置为null?

1 个答案:

答案 0 :(得分:0)

与小写/大写字母无关,但是您的问题与双引号有关。

post主题中包含的消息中,您具有4个属性:ROWTIMEROWKEYIDid。您没有名为"id"的任何属性(标签中带有双引号!)

如果您的内容格式如下,则查询将返回值:

{"ROWTIME":..., "ROWKEY":..., "id":"5ce0a41de36bcb6769fea850", "\"id\"":"5ce0a41de36bcb6769fea850"}

我很确定SELECT id, ID FROM post将返回您的期望。

或者您可以尝试在KSQL AS命令的create stream中添加双引号。