报错信息:newstudent_demo.test_spark_sql requires that the data to be inserted have the same number of columns as the target table: target table has 3 column(s) but the inserted data has 4 column(s), including 1 partition column(s) having constant value(s).

错误原因:插入的数据列数与目标表的列数不一致,在目标表中有3列,但插入的数据有4列,其中1列是分区列,其值是常数。

建议解决方案:检查插入的数据列数是否与目标表的列数一致,特别是分区列是否正确设置。如果插入的数据列数不一致,需要修改插入的数据,使其与目标表的列数一致。如果分区列设置不正确,需要修改分区列的值,使其符合目标表的分区规则。

Spark SQL 插入数据时报错:列数不一致

原文地址: https://www.cveoy.top/t/topic/otpY 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录