运行KSQLDB版本:0.12.0
我在加入流时遇到问题。
在将流创建为带窗口的内部联接查询时,右侧字段均为空,即使是属于联接条件的字段也为空。 独立运行相同的查询时,我会正常获取字段。
所以这是设置:
使用docker-compose运行服务器:
services:
ksqldb-server:
image: confluentinc/ksqldb-server:0.12.0
hostname: ksqldb-server
container_name: ksqldb-server
ports:
- "8088:8088"
environment:
KSQL_LISTENERS: http://0.0.0.0:8088
KSQL_BOOTSTRAP_SERVERS: mybroker:9092
KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
KSQL_KSQL_SCHEMA_REGISTRY_URL: http://myregistry:8081
KSQL_KSQL_STREAMS_AUTO_OFFSET_RESET: 'earliest'
流和联接定义
CREATE STREAM generic_orders (
...
clientrequestid_ string KEY,
...
) WITH (
KAFKA_TOPIC='thetopic',
VALUE_FORMAT='AVRO'
);
CREATE STREAM specific_order (
originatoruserid_ string,
request_clientid_ bigint,
bidquoteinfo_volume_ bigint
) WITH (
KAFKA_TOPIC='anothertopic',
VALUE_FORMAT='AVRO'
);
将以上两个都加入时,我也尝试将request_clientid_
设为密钥。
我怀疑由于clientrequestid_
和request_clientid_
的类型不同而无法使用,因此我创建了另一个流:
CREATE STREAM specific_order_typed AS
select originatoruserid_ ,
CAST(request_clientid_ AS string) as request_clientid_ KEY,
bidquoteinfo_volume_
FROM ice_massquote_order
EMIT CHANGES
;
那没有帮助...
这是加入的流:
CREATE STREAM enriched_orders AS
SELECT i.request_clientid_ as reqid, o.clientrequestid_ as orderreq FROM specific_order_typed i
INNER JOIN generic_order o WITHIN 1 HOURS ON o.clientrequestid_ = i.request_clientid_
EMIT CHANGES;
还尝试交换from流和join流……结果始终为空:
|623562762 |null
...
直接运行查询时,尽管我得到了期望的结果
SELECT i.request_clientid_ as reqid, o.clientrequestid_ as orderreq FROM specific_order_typed i
INNER JOIN generic_order o WITHIN 1 HOURS ON o.clientrequestid_ = i.request_clientid_
EMIT CHANGES;
|623562762 |623562762
任何人都知道发生了什么事?我已经筋疲力尽了
答案 0 :(得分:0)
所以我通过降级到0.10.2解决了我的问题。
我注意到的第一个区别是,在尝试加入原始流<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\SalesRule\Model\ResourceModel\Coupon" type="Vendor\Module\Model\ResourceModel\Coupon" />
</config>
和generic_orders
时,在specific_order
和string
之间进行比较时,我得到了一个正确的错误
bigint
然后我只需要将bigint转换为字符串(我之前也尝试使用0.12进行了尝试):
CREATE STREAM generic_orders (
...
clientrequestid_ string,
...
) WITH (
KAFKA_TOPIC='thetopic',
VALUE_FORMAT='AVRO'
);
CREATE STREAM specific_order (
originatoruserid_ string,
request_clientid_ bigint,
bidquoteinfo_volume_ bigint
) WITH (
KAFKA_TOPIC='anothertopic',
VALUE_FORMAT='AVRO'
);
最后,在读取该流时,这些值不再为null。