Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: TiSpark Insert Select错误 not enough data columns
Version: TiDB V6.2
Issue:
Executing insert into…select… based on SparkSQL reports an error. Regardless of the table, it only indicates that the source table has only 3 columns. The error message is as follows:
Cannot write to ‘us_stock_ads.ca-suspension’, not enough data columns:
Table columns: ‘symbol’, ‘startdate’, ‘enddate’, ‘reason’, ‘duration’
Data columns: ‘symbol’, ‘reason’, ‘duration’.
Executing SQL:
insert into us_stock_ads
.ca-suspension
(symbol,
startDate,
endDate,
reason,
duration)
SELECT replace(replace(replace(replace(STOCKCODE,‘.F’,‘.US’),‘.A’,‘.US’),‘.O’,‘.US’),‘.N’,‘.US’) as symbol,
SuspensionStartDate as startDate,
SuspensionEndDate as endDate,
ResumptionReason as reason,
SuspensionDuration as duration
FROM us_stock.ccs_SuspensionResumption
spark-defaults.conf file content:
spark.tispark.pd.addresses x.x.x.x:2379
spark.sql.extensions org.apache.spark.sql.TiExtensions
spark.sql.catalog.tidb_catalog org.apache.spark.sql.catalyst.catalog.TiCatalog
spark.sql.catalog.tidb_catalog.pd.addresses x.x.x.x:2379
spark.tispark.write.allow_spark_sql true