私はScalaでSparkを使用しており、集約された列は匿名です。データセットから複数の列の名前を変更する便利な方法はありますか?私はas
でスキーマを当てることを考えましたが、キー列は構造体(groupBy
操作のため)であり、case class
を定義する方法を見つけることができません。StructType
です。集約列に名前を付ける方法は?
私は次のようにスキーマを定義しようとした:
val returnSchema = StructType(StructField("edge", StructType(StructField("src", IntegerType, true),
StructField("dst", IntegerType), true)),
StructField("count", LongType, true))
edge_count.as[returnSchema]
を私はコンパイルエラーを得た:
Message: <console>:74: error: overloaded method value apply with alternatives:
(fields: Array[org.apache.spark.sql.types.StructField])org.apache.spark.sql.types.StructType <and>
(fields: java.util.List[org.apache.spark.sql.types.StructField])org.apache.spark.sql.types.StructType <and>
(fields: Seq[org.apache.spark.sql.types.StructField])org.apache.spark.sql.types.StructType
cannot be applied to (org.apache.spark.sql.types.StructField, org.apache.spark.sql.types.StructField, Boolean)
val returnSchema = StructType(StructField("edge", StructType(StructField("src", IntegerType, true),
あなたは私たちのコードを示してもらえますか?だから、私はより良いアプローチを策定することができますか? –
3つの列を持つデータセットを持っているようなふりをする。最初の2つでグループ化し、3番目にグループ化します。キーはタプルです。私はスパーク1.6.2です。ありがとう@AlbertoBonsanto! – Emre