使用Kafka Connect时,如何根据AVRO方案转换所有时间戳字段?

发布于 2025-02-11 00:16:43 字数 747 浏览 1 评论 0原文

在我们的数据库中,我们有20多个字段,我们需要从长时间转换为时间戳。为什么没有通用解决方案来传输所有这些值?

我知道我可以定义:

"transforms":"tsFormat",
"transforms.tsFormat.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormat.target.type": "string",
"transforms.tsFormat.field": "ts_col1",
"transforms.tsFormat.field": "ts_col2",

但这对我们来说不是解决方案。当我们在DB中添加新的时间戳时,我们也需要更新连接器,

是否有一些通用解决方案可以根据AVRO模式转换所有字段?

我们正在使用Debezium,在所有时间戳字段中都会创建类似的东西:

    {
      "name": "PLATNOST_DO",
      "type": {
        "type": "long",
        "connect.version": 1,
        "connect.name": "io.debezium.time.Timestamp"
      }
    },

因此,如何使用connect.name ='io.debezium.time.timestamp'找到所有类型

In our database we have over 20 fields which we need to transform from long to timestamp. Why there is no generic solution to transfer all this value ?

I know I can define:

"transforms":"tsFormat",
"transforms.tsFormat.type": "org.apache.kafka.connect.transforms.TimestampConverter$Value",
"transforms.tsFormat.target.type": "string",
"transforms.tsFormat.field": "ts_col1",
"transforms.tsFormat.field": "ts_col2",

but this is not solution for us. When we add new timestamp to db we need to update connector too

is there some generic solution to transform all fields according to avro schema ?

We are using debezium which for all timestamp fields create something like this:

    {
      "name": "PLATNOST_DO",
      "type": {
        "type": "long",
        "connect.version": 1,
        "connect.name": "io.debezium.time.Timestamp"
      }
    },

so how to find all type with connect.name = 'io.debezium.time.Timestamp' and transform it to timestamp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相对绾红妆 2025-02-18 00:16:43

您需要编写自己的转换,以便能够动态迭代记录模式,检查类型并进行转换。

因此,为什么它们被称为简单消息转换。

另外,也许仔细研究Debezium属性,以查看是否缺少设置可以改变时间戳的产生方式。

You'd need to write your own transform to be able to dynamically iterate of the record schema, check the types, and do the conversion.

Thus why they are called simple message transforms.

Alternatively, maybe take a closer look at the Debezium properties to see if there is a missing setting that alters how timestamps get produced.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文