为什么 Spark Sql 排除了 Inet 数据类型?
Why does Spark Sql Exclude the Inet Data Type?
我有一个在模式中使用 inet
类型的 postgres 数据库 (9.2)。我正在尝试使用 Spark (1.6) 写信给 postgres。
df.write.mode(mode).jdbc(db, table, props)
我正在将架构应用于 df;
context.createDataFrame(rdd, schema())
并由于架构不匹配而出现 SPARK-13286 中描述的所有 BatchUpdateException 错误。该架构是 StructFields 的 StructType,需要 Spark Sql DataType。有没有办法让它与任何现有的 Spark Sql 数据类型一起工作?
Why does Spark Sql Exclude the Inet Data Type?
实际上,Spark 无法支持不同 JDBC 来源(不仅是 RDBMS)使用的所有自定义类型。
way to make this work with any of the existing Spark Sql Data Types?
您可以使用查询转换为 Spark 可使用的类型(未测试):
spark.read.jdbc(url, "(SELECT CAST(inet_col AS TEXT) FROM table) AS t")
我有一个在模式中使用 inet
类型的 postgres 数据库 (9.2)。我正在尝试使用 Spark (1.6) 写信给 postgres。
df.write.mode(mode).jdbc(db, table, props)
我正在将架构应用于 df;
context.createDataFrame(rdd, schema())
并由于架构不匹配而出现 SPARK-13286 中描述的所有 BatchUpdateException 错误。该架构是 StructFields 的 StructType,需要 Spark Sql DataType。有没有办法让它与任何现有的 Spark Sql 数据类型一起工作?
Why does Spark Sql Exclude the Inet Data Type?
实际上,Spark 无法支持不同 JDBC 来源(不仅是 RDBMS)使用的所有自定义类型。
way to make this work with any of the existing Spark Sql Data Types?
您可以使用查询转换为 Spark 可使用的类型(未测试):
spark.read.jdbc(url, "(SELECT CAST(inet_col AS TEXT) FROM table) AS t")