0
私はJDBC経由でデータフレームを保存しようとしています(ポストグルに)。フィールドの1つはタイプArray[Array[Int]]
です。Spark DataFrame to JDBC - 配列のJDBCタイプを取得できません。>
val df = readings
.map { case ((a, b), (_, d, e, arrayArrayInt)) => (a, b, d, e, arrayArrayInt) }
.toDF("A", "B", "D", "E", "arrays")
edgesDF
.withColumn("arrays_", edgesDF.col("arrays").cast(ArrayType(ArrayType(IntegerType))))
.drop("arrays")
.withColumnRenamed("arrays_", "arrays")
.write
.mode(SaveMode.ErrorIfExists)
.jdbc(url = dbURLWithSchema, table = "mytable", connectionProperties = dbProps)
しかし、それはまだ同じ例外で失敗:すべてのキャストがなければ、それは
Exception in thread "main" java.lang.IllegalArgumentException: Can't
get JDBC type for array<array<int>>
at ... (JdbcUtils.scala:148)
で失敗し、私は変革を導くために、配列のデータ型に明示的なキャストを追加しました。
どのようにしてこのデータをDBに保存できますか?あなたがデータベースにarray<array<int>>
を保存することができ
Postgresは配列をサポートしています。 – philantrovert
@philantrovertごめんなさい、以前の質問でポストグルを見る –