【发布时间】:2021-03-01 12:09:52
【问题描述】:
美好的一天。我正在部署一个流式作业以将数据从 Spark (Scala) 插入到 Postgres。
df.select("col1","col2").write.mode(SaveMode.Append).jdbc(url, "tableName", connectionProperties)
这里 col2 在数据帧 df 中有 uuid 值,但它是字符串数据类型。当它尝试插入将 col2 列定义为类型 uuid 的表中时,它会以 Column is of type uuid but expression is of type character varying 失败。有人可以帮我解决这个问题。 ?
谢谢。
【问题讨论】:
-
您可以在创建连接属性时尝试使用此行添加额外的属性。
connectionProps.setProperty("stringtype", "unspecified") -
我已将其添加为答案。如果它对您有帮助并且对您有用,您可以接受它作为答案。
标签: java postgresql scala apache-spark