apache-kafka - KSQL 表 - 表连接未按预期工作
问题描述
我正在尝试在 KSQL 中加入两个表。这个想法是在连接查询之上创建一个持久表。我正在使用完全外部联接。
来源 1: Kafka 主题 -> KSQL 流 -> KSQL 表
表格顺序中的示例数据:
Key,Product_Name,Product_category
Product_1|Category_1|2018-08-25,Product_1,Category_1
Product_2|Category_2|2018-08-25,Product_2,Category_2
Product_3|Category_3|2018-08-25,Product_3,Category_3
Product_4|Category_4|2018-08-25,Product_4,Category_4
Product_5|Category_5|2018-08-25,Product_5,Category_5
来源 2: Kafka 主题 -> KSQL 流 -> KSQL 表
表产品中的示例数据:
Key,Product_Name,Product_category
Product_1|Category_1|2018-08-25,Product_1,Category_1
Product_2|Category_2|2018-08-25,Product_2,Category_2
Product_3|Category_3|2018-08-25,Product_3,Category_3
Product_4|Category_4|2018-08-25,Product_4,Category_4
Product_5|Category_5|2018-08-25,Product_5,Category_5
源 1 中的数据流是连续的,而源 2 中的数据流是固定的,每天一次。
加盟查询:
Create Table Order_Joined_Product as
select
A.key as Order_Key,
A.Product_Name as Order_Product,
A.Product_Category as Order_category,
B.key as Product_Key,
B.Product_Name as Product,
B.Product_Category as Product_category
from Order as A
FULL JOIN PRODUCT as B on A.Key=B.Key
现在,问题是如果我对连接表进行计数,Order_Key 计数会随着时间的推移而增加,而 Product_Key 的计数会随着时间的推移而减少。
我想要实现的是到一天结束时,我想查看源 1 中而不是 2 中的产品数量以及源 2 中而不是 1 中的产品数量。
解决方案
推荐阅读
- java - 枚举通用抽象类构造函数
- typescript-generics - 如何替换类 intypescript 中的所有返回类型
- python - 从字典字典中,返回内部字典列表,用键更新
- powerbi - M 函数中的条件 FOR/WHILE - Power BI 中的 Paginate API
- java - 是否有高级故障排除技术可以尝试调试在关闭时挂起的 JavaFX 进程?
- python - 有没有办法将变量排入队列?
- r - 可互换的模拟和将数据写入文件
- rust - 每个工作区成员的货物默认构建目标
- c# - 如何获取具有列表的属性的值
在 C# 中? - flutter - 在屏幕上使用多个小部件显示快照数据的正确方法