Skip to content

TROUBLESHOOTING cast errors pml model

In this chapter, we present job and plan uses cases.

When does it arrive

Sometimes when you are creating your own PML graph, and you want to post process the data (for example with k means). You want to get the meta-data of the fitted model. In that case you will use the following line :

Transformer stage = stages[3];

You will in that case get the following stacktrace :

18/06/05 10:29:25 ERROR Executor task launch worker for task 11 org.apache.spark.executor.Executor: Exception in task 0.0 in stage 11.0 (TID 11)
java.lang.ClassCastException: cannot be cast to
at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIterator.processNext(Unknown Source)
at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(
at org.apache.spark.sql.execution.WholeStageCodegenExec$$anonfun$8$$anon$1.hasNext(WholeStageCodegenExec.scala:395)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:234)
at org.apache.spark.sql.execution.SparkPlan$$anonfun$2.apply(SparkPlan.scala:228)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$25.apply(RDD.scala:827)
at org.apache.spark.rdd.RDD$$anonfun$mapPartitionsInternal$1$$anonfun$apply$25.apply(RDD.scala:827)
at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:38)
at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:323)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:287)
at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
at org.apache.spark.executor.Executor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

How to correct it

This means that the number 3 that you put in your line isn't pointing to the right position of the stage into your Mllib node. it is pointing to another stage, here, for instance, it's pointing to the stage 4 (0 is an index too) and it is a vector assembler whereas my means is the stage 5. So i just have to correct the value :

Transformer stage = stages[4];