You may get a different result due to the upgrading of Spark 3.0: Fail to parse '2012-8-7 13:41:28' in the new parser. You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0, or set to CORRECTED and treat it as an invalid datetime string.
)
加如下配置即可
// 加入.config("spark.sql.legacy.timeParserPolicy", "LEGACY")配置一下就不报错了
val spark: SparkSession = SparkSession
.builder()
.appName("Spark SQL")
.master("local")
.config("spark.sql.legacy.timeParserPolicy", "LEGACY")
.getOrCreate()