Cannot extract value from entity

(Jonathan Spooner) #1

I've had this script running for some time but it suddenly started throwing an error. The error message looks like my device_id is in a nested array in my table but after inspecting the table it is not.

def esConfig(): Map[String,String] = {
  Map("" -> "device_id")

My Table
|device_id                                  |
|g.40     |
|a.E2     |

Running saveToEs throws this error [ScalaMapFieldExtractor for field [[device_id]]] cannot extract value from entity [class java.lang.String]

EsSpark.saveToEs(aDF.rdd, "production-devices-spark-shell/device", esConfig)

16/11/18 15:20:06 WARN TaskSetManager: Lost task 10.0 in stage 79.0 (TID 3312, org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: [ScalaMapFieldExtractor for field [[device_id]]] cannot extract value from entity [class java.lang.String] | instance [[ds.289d90c249cec7becf3cfde39f0bbe028fcf4ce4]]
	at org.elasticsearch.hadoop.serialization.bulk.AbstractBulkFactory$FieldWriter.write(
	at org.elasticsearch.hadoop.serialization.bulk.TemplatedBulk.writeTemplate(
	at org.elasticsearch.hadoop.serialization.bulk.TemplatedBulk.write(
	at org.elasticsearch.spark.rdd.EsRDDWriter.write(EsRDDWriter.scala:67)
	at org.elasticsearch.spark.rdd.EsSpark$$anonfun$doSaveToEs$1.apply(EsSpark.scala:102)
	at org.elasticsearch.spark.rdd.EsSpark$$anonfun$doSaveToEs$1.apply(EsSpark.scala:102)
	at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:70)
	at org.apache.spark.executor.Executor$
	at java.util.concurrent.ThreadPoolExecutor.runWorker(
	at java.util.concurrent.ThreadPoolExecutor$

ScalaMapFieldExtractor Cannot extract value from entity
(Jonathan Spooner) #2

This issue was resolved by mapping my data set to a Device case class. My script had this operation further up the lineage chain and it appears it must be the last step before handing off the rdd to EsSpark.

case class Device(device_id: String)

val esDF = {
  case Row(device_id: String) => Device(device_id)
EsSpark.saveToEs(esDF.rdd, "devices-spark-shell/device", esConfig)

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.