I'm using Scala + Spark 2.0 and trying to write an UDAF that has an Array of tuples as its internal buffer as well as its return type: ...
def bufferSchema = new StructType().add("midResults", ArrayType( StructType(Array(StructField("a", DoubleType),StructField("b", DoubleType))) ))
def dataType: DataType = ArrayType( StructType(Array(StructField( "a", DoubleType),StructField("b", DoubleType))) )
And this is how I update the buffer
def update(buffer: MutableAggregationBuffer, input: Row) = {
buffer(0) = buffer.getAs[mutable.WrappedArray[(Double,Double)]](3) ++ Array((3.0,4.0))
}
But I get the following exception:
java.lang.ArrayStoreException: org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
This pattern works if I have a simple Array of Double..