【问题标题】:Binary avro type mapping to Postgres?二进制avro类型映射到Postgres?
【发布时间】:2020-05-29 12:33:17
【问题描述】:

我的 Nifi 流程有以下 avro 定义,我正在从 BLOB 数据库列中读取 a。我在我的 avro 定义中将“xxPZPVSTREAM”列映射为“字节”类型

{
    "namespace":"a.b.c",
    "name":"pc_history",
    "type":"record",
    "fields":   [
        {"name":"COMMITDATETIME","type":["null",{"type":"long","logicalType":"timestamp-millis"}]},
        ....
        {"name":"xxPZPVSTREAM","type":["bytes","null"]},
        {"name":"xxx","type":["string","null"]}
    ]
}

当我尝试将映射数据写入 Postgres 数据库时,出现此错误

org.postgresql.util.PSQLException: Can’t infer the SQL type to use for an instance of [Ljava.lang.Byte;. Use setObject() woth an explicit Types values to specify the type to use.

我可以在 avro 定义中添加额外的元信息以允许 Nifi 处理器正确映射此二进制列吗?

【问题讨论】:

    标签: postgresql apache-nifi avro


    【解决方案1】:

    您没有说您使用的是哪个处理器,但这应该得到PutDatabaseRecord 的支持。该处理器是您想要使用的,因为它应该将字节数组字段映射到 blob。如果没有,请加入 nifi-dev 邮件列表并告诉我们。

    【讨论】:

    • 谢谢 - 这是一个 ExecuteSQLRecord 处理器,我们正在尝试从 oracle DB 读取序列化的 blob,查询很好,因为映射到 avro 架构失败并出现上述错误。
    猜你喜欢
    • 1970-01-01
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多