Flink CDC这个错误有同学遇到吗?

Flink CDC这个错误有同学遇到吗?Caused by: java.io.IOException: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO test4(id, name) VALUES (14, '14440000') ON CONFLICT (id) DO UPDATE SET id=EXCLUDED.id, name=EXCLUDED.name was aborted: ERROR: modification of distribution columns in OnConflictUpdate is not supported Call getNextException to see other errors in the batch.
at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:222)
... 8 more
Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO test4(id, name) VALUES (14, '14440000') ON CONFLICT (id) DO UPDATE SET id=EXCLUDED.id, name=EXCLUDED.name was aborted: ERROR: modification of distribution columns in OnConflictUpdate is not supported Call getNextException to see other errors in the batch.
at org.postgresql.jdbc.BatchResultHandler.handleCompletion(BatchResultHandler.java:186)
at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:872)
at org.postgresql.jdbc.PgStatement.executeBatch(PgStatement.java:910)
at org.postgresql.jdbc.PgPreparedStatement.executeBatch(PgPreparedStatement.java:1638)
at org.apache.flink.connector.jdbc.statement.FieldNamedPreparedStatementImpl.executeBatch(FieldNamedPreparedStatementImpl.java:65)
at org.apache.flink.connector.jdbc.internal.executor.TableSimpleStatementExecutor.executeBatch(TableSimpleStatementExecutor.java:64)
at org.apache.flink.connector.jdbc.internal.executor.TableBufferReducedStatementExecutor.executeBatch(TableBufferReducedStatementExecutor.java:101)
at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.attemptFlush(JdbcOutputFormat.java:246)
at org.apache.flink.connector.jdbc.internal.JdbcOutputFormat.flush(JdbcOutputFormat.java:216)
... 8 more
Caused by: org.postgresql.util.PSQLException: ERROR: modification of distribution columns in OnConflictUpdate is not supported
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2365)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:355)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:315)
at org.postgresql.jdbc.PgStatement.internalExecuteBatch(PgStatement.java:868)

展开
收起
真的很搞笑 2023-10-10 19:16:12 363 分享 版权
1 条回答
写回答
取消 提交回答
  • 公众号:网络技术联盟站,InfoQ签约作者,阿里云社区签约作者,华为云 云享专家,BOSS直聘 创作王者,腾讯课堂创作领航员,博客+论坛:https://www.wljslmz.cn,工程师导航:https://www.wljslmz.com

    这个错误是由于在使用 ON CONFLICT UPDATE 时,修改分布列(distribution columns)是不被 PostgreSQL 支持的。

    解决该问题的方法是修改你的 SQL 查询语句,确保不去修改分布列。你可以考虑以下两种方式:

    更换使用其他唯一约束列进行冲突判断和更新。如果你的表中有其他唯一约束列,可以将其作为 ON CONFLICT 子句中的冲突目标列,而不去修改分布列。

    不使用 ON CONFLICT UPDATE 子句,而是在应用程序中实现相应的逻辑来处理冲突。在 Flink CDC 中,你可以通过编写自定义函数或者使用状态来实现对冲突数据的处理。

    2023-10-11 07:48:13
    赞同 展开评论

实时计算Flink版是阿里云提供的全托管Serverless Flink云服务,基于 Apache Flink 构建的企业级、高性能实时大数据处理系统。提供全托管版 Flink 集群和引擎,提高作业开发运维效率。

还有其他疑问?
咨询AI助理