简体   繁体   English

无法从表 KSQL 中获取数据

[英]cannot get data from table KSQL

I create a rekeyed stream我创建了一个重新加密的流

CREATE STREAM details_stream_rekeyed2 as \
  select CONCAT(IdSeq,IdTime,'') as root,ServerId,Server,\
         IdTime ,IdSeq \
  from voip_details_stream  \
  partition by root;

select from this stream and i get > 100 items从这个流中选择,我得到 > 100 个项目

then i try to create a table然后我尝试创建一个表

create table voip_details_table3 \
  (ROOT varchar,ServerId long , Server varchar ,IdTime varchar,IdSeq long ) \
  with ( kafka_topic = 'DETAILS_STREAM_REKEYED2', \
         value_format = 'json',\
         key='ROOT');

when i run当我跑步时

SELECT ROWKEY,ROOT  FROM VOIP_DETAILS_TABLE3;

i get the only less than 10 items likes ;我得到的只有不到 10 个喜欢;

12018-04-04T18:56:35.080-04:00 | 12018-04-04T18:56:35.080-04:00

i run the command:我运行命令:

kafkacat -C -K: -b "$BROKER_LIST" -f 'Key:    %k\nKey Bytes: %K\nValue:  %s\nValue Bytes: %S\n\n' -t DETAILS_STREAM_REKEYED2

everething is ok.一切正常。 and i get data likes我得到数据喜欢

 Key:    12018-02-05T15:16:07.113-05:00
 Key Bytes: 30
 Value:  {"SERVER":null,"IDSEQ":1,"ROOT":"12018-02-05T15:16:07.113-05:00","SERVERID":null,"SESSIONIDTIME":"2018-02-05T15:16:07.113-05:00"}

Value Bytes: 158值字节:158

where the problem ?问题出在哪里?

A KSQL table differs from a KSQL Stream, in that it gives you the latest value for a given key . KSQL 表与 KSQL 流的不同之处在于它为您提供给定 key最新值 So if you are expecting to see the same number of messages in your table as your source stream, you should have the same number of unique keys.因此,如果您希望在表中看到与源流相同数量的消息,您应该拥有相同数量的唯一键。

If you're seeing fewer messages then it suggests that ROOT is not unique.如果您看到的消息较少,则表明ROOT不是唯一的。

Depending on the problem that you're modelling, you should either :根据您建模的问题,您应该:

  • (a) be using a Stream not a Table, or (a) 使用流而不是表,或
  • (b) change the key that you are using (b) 更改您正在使用的密钥

Ref:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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