首页 > 解决方案 > Spark 3.0 scala.None$ 不是字符串模式的有效外部类型

问题描述

在使用 elasticsearch-hadoop 库读取具有空属性的弹性搜索索引时,出现异常

Caused by: java.lang.RuntimeException: scala.None$ is not a valid external type for schema of string

github 中存在相同的开放缺陷,并具有重现它的步骤:https ://github.com/elastic/elasticsearch-hadoop/issues/1635

Spark:3.1.1
Elasticsearch-Hadoop:elasticsearch-spark-30_2.12-7.12.0
Elasticsearch:2.3.4

标签: scalaapache-sparkelasticsearchelasticsearch-hadoop

解决方案


它通过设置 elasticsearch-hadoop 属性es.field.read.empty.as.null = no

.option("es.field.read.empty.as.null", "no")

来自 Elasticsearch链接
es.field.read.empty.as.null(默认是)elasticsearch
-hadoop 是否会将空字段视为 null。


推荐阅读