简体   繁体   English

列是 uuid 类型,但表达式是 Spark Scala 中不同的字符类型

[英]Column is of type uuid but expression is of type character varying in Spark Scala

Good day.再会。 I am deploying a streaming job to insert data from Spark (Scala) to Postgres.我正在部署一个流式作业以将数据从 Spark (Scala) 插入到 Postgres。

df.select("col1","col2").write.mode(SaveMode.Append).jdbc(url, "tableName", connectionProperties)

Here col2 is having uuid values in the dataframe df, but it is a string datatype.这里 col2 在 dataframe df 中有 uuid 值,但它是字符串数据类型。 When it tries to insert in to the table that has col2 column defined as type uuid its failing with the Column is of type uuid but expression is of type character varying .当它尝试插入将 col2 列定义为 uuid 类型的表中时,它的失败与Column is of type uuid but expression is of type character varying Can someone help me with a workaround for this.有人可以帮我解决这个问题。 ? ?

Thank you.谢谢你。

When you have column column in dataframe that has string data type but had values of type UUID then you can set the specific property in your connection properties and that will allow you to save your dataframe.当 dataframe 中的列具有字符串数据类型但具有 UUID 类型的值时,您可以在连接属性中设置特定属性,这将允许您保存 dataframe。 If you don't set that property it will not allow you to save the data in the sql/postgres table, if the column has datatype of UUID.如果您不设置该属性,如果该列的数据类型为 UUID,它将不允许您将数据保存在 sql/postgres 表中。

You can set this property in the Connection Properties您可以在连接属性中设置此属性

connectionProps.setProperty("stringtype", "unspecified")

Setting the above property will allow you to save the string type column having UUID values in the dataframe to a column of type UUID in the postgres database.设置上述属性将允许您将 dataframe 中具有 UUID 值的字符串类型列保存到 postgres 数据库中 UUID 类型的列。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JOOQ-列“ id”的类型为uuid,但表达式的类型为字符变化 - JOOQ - column “id” is of type uuid but expression is of type character varying java sql error列的类型为整数,但表达式的类型为字符变化 - java sql error column is of type integer but expression is of type character varying PostgreSQL 提示:您需要重写或转换表达式。 “状态”列的类型是状态,但表达式的类型是字符变化 - PostgreSQL Hint: You will need to rewrite or cast the expression. column “state” is of type status but expression is of type character varying org.postgresql.util.PSQLException:错误:列“标签”是 jsonb 类型,但表达式的类型是字符变化 - org.postgresql.util.PSQLException: ERROR: column "tags" is of type jsonb but expression is of type character varying 错误:列“DOJ”的类型是没有时区的时间戳,但表达式的类型是字符变化 - ERROR: column "DOJ" is of type timestamp without time zone but expression is of type character varying 在字符类型变化的列上使用聚合函数 - Using aggregate function on a column of type character varying 错误: <column-name> 是没有时区的时间,但表达的类型字符是变化的 - Error: the <column-name> is of time without time zone but expression is of type character varying UUID 生成的字符类型 - Type of Character generated by UUID 当我在 Jooq 中插入日期时,出现此错误:column creation_date is of type timestamp with time zone but expression is of type character varying - When I insert a date in Jooq, I get this error: column creation_date is of type timestamp with time zone but expression is of type character varying 错误:列“id”是 uuid 类型,但表达式是 bytea 类型 - ERROR: column "id" is of type uuid but expression is of type bytea
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM