Hi everyone, I am trying to enrich kafka streaming...
# troubleshooting
h
Hi everyone, I am trying to enrich kafka streaming data stream
T24SB.ODS_STMT_ENTRY
using oracle database table. The oracle database table is inserted/updated daily (or hourly) by other ETL jobs. How can flink re-read the enrichment table regularly to get the latest data while the streaming job is still running? I tried lookup cache and lookup join with the FOR SYSTEM_TIME AS OF statement. However, flink only scans the oracle table once and then finishes. Here are my relevant codes:
CREATE TABLE T24SB.ODS_STMT_ENTRY (
TRANSACTION_TIME TIMESTAMP(3) METADATA FROM 'timestamp',
WATERMARK FOR TRANSACTION_TIME AS TRANSACTION_TIME - INTERVAL '1' SECOND,
TRANS_REFERENCE STRING
WITH (
'connector' = 'kafka',
...
);
CREATE TABLE WALLET_TRANSACTION_TMP (
TRACE_ID STRING,
DESCRIPTION STRING,
TIME_UPDATE TIMESTAMP(1),
WATERMARK FOR TIME_UPDATE AS TIME_UPDATE,
PRIMARY KEY (TRACE_ID) NOT ENFORCED
)
WITH (
'connector' = 'jdbc',
...
'lookup.cache'='PARTIAL',
'lookup.partial-cache.expire-after-write'='3s'
);
(insert into tar_table)
select STMT.TRANSACTION_TIME, WL.TRACE_ID, WL.DESCRIPTION
FROM
T24SB.ODS_STMT_ENTRY STMT
LEFT JOIN
WALLET_TRANSACTION_TMP FOR SYSTEM_TIME AS OF STMT.TRANSACTION_TIME AS WL on STMT.TRANS_REFERENCE =WL.TRACE_ID ;
This is the tracking result on the web interface.
m
h
@Martijn Visser I used lookup join as in the example code but it doesn't work. Even though I used left join, no records were inserted. For example, in my image above, there are 4 records sent but no records are recorded in the collect table sink
h
bạn đang dùng
Event Time Temporal Join
, ko phải lookup join thì phải, thử bỏ WATERMARK ở bảng WALLET_TRANSACTION_TMP xem
h
@hùng trần việt mình bỏ thì bị lỗi bạn à [ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.ValidationException: Event-Time Temporal Table Join requires both primary key and row time attribute in versioned table, but no row time attribute can be found.
@hùng trần việt theo mình hiểu thì cái mình đang dùng thì cần bảng lookup là bảng append, chỉ ghi thêm các thay đổi của dữ liệu mà không update. Trong ví dụ của mình thì flink chỉ lấy những bản ghi mới nhất (theo PK) có
time_update
nhỏ hơn``STMT`.TRANSACTION_TIME` để thêm vào luồng stream chính. Vấn đề mình cần giải quyết là làm sao sử dụng bảng oracle upsert để enrich (ví dụ flink quét dữ liệu của bảng mỗi 1h). Hiện tại flink chỉ quét bảng oracle tại thời điểm submit sau đó finish và không quét lại nữa.
h
`The
INTERVAL
time subtraction is used to wait for late events in order to make sure the join will meet the expectation` các event của bảng WALLET_TRANSACTION_TMP đang bị bỏ qua do quá WATERMARK. Còn lỗi kia thì ở bảng T24SB.ODS_STMT_ENTRY bạn cũng bỏ dùng WATERMARK đi, dùng proctime thử xem Ví dụ giống như này: https://nightlies.apache.org/flink/flink-table-store-docs-master/docs/development/lookup-join/
h
Ok, dùng PROCTIME() có vẻ khả thi, để tôi thử. Tôi cảm ơn nhé!