Exception in thread “main“ org.apache.spark.sql.AnalysisException: Cannot write incompatible data to
•
大数据
Exception in thread “main” org.apache.spark.sql.AnalysisException: Cannot write incompatible data to table ‘`dwd`.`dim_customer_inf`’:
– Cannot safely cast ‘dwd_insert_time’: string to timestamp
– Cannot safely cast ‘dwd_modify_time’: string to timestamp
这是因为从 Spark 3.0.0 开始,Spark SQL 增加了一个安全策略,不对非同类型的数据进行强制转换,然后就会出现这个错误。
解决方法:
val spark = SparkSession.builder().config(sparkConf)
.config("spark.sql.storeAssignmentPolicy", "LEGACY")
.enableHiveSupport().getOrCreate()
本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/eaf82f98a9.html
