我有以下Spark SQL模式:
|-- route: struct (nullable = true)
| |-- originCode: string (nullable = true)
| |-- originName: string (nullable = true)
| |-- originCountry: string (nullable = true)
. . .
. . .
| |-- actualTimeAverage: double (nullable = true)
| |-- legs: array (nullable = true)
| | |-- element: array (containsNull = true)
| | | |-- element: struct (containsNull = true)
| | | | |-- tenantId: string (nullable = true)
| | | | |-- originCode: string (nullable = true)
| | | | |-- originName: string (nullable = true)
. . . . .
. . . . .
. . . . .
从route
的实例开始,我试图获取legs
数组并在定义val时声明其类型。
我尝试过:
val atlLegs: Array[Array[Row]] = atlRoute.getAs[Array[Array[Row]]](atlRoute.fieldIndex("legs"))
但是,出现此运行时错误:
scala.collection.mutable.WrappedArray$ofRef cannot be cast to [[Lorg.apache.spark.sql.Row;
java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [[Lorg.apache.spark.sql.Row;
我应该给什么作为atlLegs类型?