[英]row.getList java.lang.ClassCastException: java.math.BigDecimal cannot be cast to scala.collection.Seq
I'm trying to retrieve a list from a row with the following schema element.我正在尝试从具有以下架构元素的行中检索列表。
[info] |-- ARRAY_FIELD: array (nullable = false)
[info] | |-- element: string (containsNull = false)
When printing using打印时使用
row.getAs[WrappedArray[String]]("ARRAY_FIELD")
I get the following result我得到以下结果
WrappedArray(Some String value)
But when I attempt to print the data at that index as a list using....但是当我尝试使用...打印该索引处的数据作为列表时。
row.getList(0)
I get the following exception我收到以下异常
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to scala.collection.Seq
Does anyone have any ideas on why this happens and how it can be resolved?有没有人对为什么会发生这种情况以及如何解决有任何想法?
I was actually pulling from the wrong index in the schema.我实际上是从模式中的错误索引中提取的。 I assumed that the index for getList was based on the index of the elements shown when using df.printSchema.我假设 getList 的索引基于使用 df.printSchema 时显示的元素的索引。 But I was wrong.但是我错了。 Off by 6 postions.关闭 6 个位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.