postgresql - 使用 Apache NiFi 加载 postgres 表时出现 UUID 数据类型问题
问题描述
数据库
- Postgres 9.6
- 包含多个具有 UUID 列的表(包含每条记录的 ID)
尼菲
- 最新版本 (1.7.1)
- 使用 Avro 1.8.1(据我所知)
问题描述
使用 ExecuteSQL 处理器调度表时,会出现以下错误消息:
ExecuteSQL[id=09033e32-e840-1aed-3062-6e8cbc5551ba] ExecuteSQL[id=09033e32-e840-1aed-3062-6e8cbc5551ba] 由于 createSchema 无法处理会话:未知 SQL 类型 1111 / uuid(表:国家,列:id ) 不能转换为 Avro 类型;处理器在管理上产生了 1 秒:java.lang.IllegalArgumentException:createSchema:未知 SQL 类型 1111 / uuid(表:国家,列:id)无法转换为 Avro 类型
请注意,流文件不会从传入队列中删除,也不会发送到“失败”关系,从而导致失败尝试的无限循环。
尝试修复问题
- 我尝试启用 ExecuteSQL 处理器的Use Avro Logical Types属性,但发生了同样的错误。
可能但不是首选的解决方案
- 我目前从每个表中执行一个 SELECT *。一个可能的解决方案(我认为)是指定每一列,并让查询将 uuid 转换为字符串。虽然这可行,但我强烈希望不必单独列出每一列。
最后一点
- 我确实找到了这张 Jira 票:https ://issues.apache.org/jira/browse/AVRO-1962 但是,我不确定如何解释这一点。实施与否?它应该工作还是不工作?
解决方案
I believe UUID is not a standard JDBC type and is specific to Postgres.
The JDBC types class shows that SQL type 1111 is "OTHER":
/**
* The constant in the Java programming language that indicates
* that the SQL type is database-specific and
* gets mapped to a Java object that can be accessed via
* the methods <code>getObject</code> and <code>setObject</code>.
*/
public final static int OTHER = 1111;
So I'm not sure how NiFi could know what to do here because it could be anything depending on the type of DB.
推荐阅读
- javascript - 通过单击导航栏实现将鼠标悬停到垂直下拉列表的水平下拉列表
- c# - WEB API OdataController POST 调用返回 406 Not Acceptable
- arrays - 有没有办法在 Excel-VBA 中显示或查看分配的内存或数组的使用情况?
- html - 引导响应中的不同表列和行
- markdown - 使用 Markdown 文件动态生成单页
- python - 如何让 numpy.zeros() 和 (numpy.ones() * 255) 分别生成黑白图像?
- postgresql - 如何在 kubernetes 上使用密码连接到 psql
- android - Android 在单独的线程中将数据库数据同步到服务器
- android - 如何在使用 ListAdapter 和 DiffUtill 的 RecyclerView 中进行搜索?
- laravel - Laravel 合并关系