简体   繁体   English

row.getList java.lang.ClassCastException:java.math.BigDecimal 不能转换为 scala.collection.Seq

[英]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.

相关问题 Spark scala: java.lang.ClassCastException: java.lang.Integer cannot be cast to scala.collection.Seq - Spark scala: java.lang.ClassCastException: java.lang.Integer cannot be cast to scala.collection.Seq java.lang.ClassCastException: org.apache.spark.sql.Column cannot be cast to scala.collection.Seq - java.lang.ClassCastException: org.apache.spark.sql.Column cannot be cast to scala.collection.Seq java.lang.ClassCast errors.GenericRowWithSchema 不能转换为 scala.collection.Seq - java.lang.ClassCast errors.GenericRowWithSchema cannot be cast to scala.collection.Seq Spark java.lang.ClassCastException: scala.collection.mutable.WrappedArray 无法转换为 scala.collection.Seq.immutable - Spark java.lang.ClassCastException: scala.collection.mutable.WrappedArray cannot be cast to scala.collection.immutable.Seq 编译错误? java.lang.ClassCastException:scala.collection.mutable.WrappedArray $ ofRef无法强制转换为java.lang.Integer - Compiler bug? java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to java.lang.Integer 将scala.math.BigDecimal转换为java.math.BigDecimal? - Convert scala.math.BigDecimal to java.math.BigDecimal? 将java.math.BigDecimal转换为scala.math.BigDecimal? - Convert java.math.BigDecimal to scala.math.BigDecimal? Spark java.lang.ClassCastException:scala.collection.mutable.WrappedArray$ofRef 无法转换为 java.util.ArrayList - Spark java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to java.util.ArrayList “主要” java.lang.ClassCastException:[Lscala.Tuple2; 无法在Spark MLlib LDA中强制转换为scala.Tuple2 - “main” java.lang.ClassCastException: [Lscala.Tuple2; cannot be cast to scala.Tuple2 in Spark MLlib LDA 转换scala.collection.Seq的Java对象 <String> 到python列表 - Convert Java object of scala.collection.Seq<String> to python list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM