欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

spark报错java.lang.NullPointerException:Nullvalueappearedinnon-nullablefield:toplevelProduct

时间:2023-05-04
报错内容

java.lang.NullPointerException: Null value appeared in non-nullable field:
top level Product input object
If the schema is inferred from a Scala tuple/case class, or a Java bean, please try to use scala.Option[_] or other nullable types (e.g、java.lang.Integer instead of int/scala.Int).

报错的代码

package com.testimport org.apache.spark.sql.{Dataset, SparkSession}import java.langimport scala.collection.mutable.ListBufferimport scala.util.control.Breaks.{break, breakable}object scalaDemo1 { def main(args: Array[String]): Unit = { val spark = SparkSession.builder() .master("local[*]") .appName("yy") .getOrCreate() val sc = spark.sparkContext spark.sparkContext.setLogLevel("ERROR") // For implicit conversions like converting RDDs to Dataframes import spark.implicits._ import org.apache.spark.sql.functions._ //解决:无法重载方法agg // 方法1 val

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。