欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

org.apache.spark.sql.AnalysisException: Try to map struct<>to Tuple1 异常

程序员文章站 2022-07-11 08:29:57
...
spark.read.parquet(mypath).as[MyEntity]会遇到下面异常


org.apache.spark.sql.AnalysisException: Try to map struct<uid:string> to Tuple1, but failed as the number of fields does not line up.;
	at org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveDeserializer$.org$apache$spark$sql$catalyst$analysis$Analyzer$ResolveDeserializer$$fail(Analyzer.scala:2044)
	at org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveDeserializer$.org$apache$spark$sql$catalyst$analysis$Analyzer$ResolveDeserializer$$validateTopLevelTupleFields(Analyzer.scala:2061)
	at org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveDeserializer$$anonfun$apply$32$$anonfun$applyOrElse$12.applyOrElse(Analyzer.scala:2035)
	at org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveDeserializer$$anonfun$apply$32$$anonfun$applyOrElse$12.applyOrElse(Analyzer.scala:2027)


在read之前需要:

import spark.implicits._