0
スパークSQ内の特定の要素fromaアレイを選択しながらエラー私は、配列の唯一の0番目の要素を選択するために、</p> <p>は実際に私がしたい値をスパークSQLを使用してJSONを読み、印刷しようとしています
I完全な配列を選択しようと、それは動作しますが、私は配列から0番目の要素を選択しようとすると、それは
val events = sc.parallelize("""{"toid":"osgb4000000031043205","point":[508180.748,195333.973],"index":1}""" :: Nil)
val schema = new StructType().add("toid",StringType,true).add("point",DataTypes.createArrayType(DoubleType,true),true).add("index",StringType,true)
val df = sqlContext.read.schema(schema).json(events)
df.show
+--------------------+--------------------+-----+
| toid| point|index|
+--------------------+--------------------+-----+
|osgb4000000031043205|[508180.748, 1953...| 1|
+--------------------+--------------------+-----+
scala> df.select("point")[0].show
<console>:1: error: identifier expected but integer literal found.
df.select("point")[0].show
^
scala> df.select("point")(0).show
<console>:48: error: type mismatch;
found : Int(0)
required: String
df.select("point")(0).show
を失敗誰かがこのエラーで私を助けてもらえますか?