如何编写kafka connect查询来使用时间戳模式查询两个特定日期之间的数据

q8l4jmvw  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(247)

我正在编写一个kakfa jdbc源连接器来查询postgres表中的两个日期(开始日期和结束日期),并希望连接器在从结束日期到开始日期的每一天运行查询。这可能吗?从日期介于“2020-08-01”和结束日期=“2020-10-31”之间的表中选择*

kzmpq1sx

kzmpq1sx1#

您可以通过定义 filter.condition .
链接中给出了一个示例,如下所示:

transforms=filterDateExample

# Use the 'io.confluent.connect.transforms.Filter$Value' as the source (record 'value') on which

# 'filter.condition' shall be applied.

transforms.filterDateExample.type=io.confluent.connect.transforms.Filter$Value
transforms.filterDateExample.filter.condition=$.key[?(@.date >= "2020-08-01" && @.date <= "2020-10-31")]

# Use 'include' to pass through all records that match the predicate.

transforms.filterDateExample.filter.type=include

# Use the 'fail' behavior to throw an exception and fail the connector task when the record does

# not have the field(s) used in the 'filter.condition'.

transforms.filterDateExample.missing.or.null.behavior=fail

它看起来无法识别日期类型,因此您可能还需要查看时间戳转换器。

相关问题