TiSpark Insert Select Error: Not Enough Data Columns

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

| username: ShawU

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

| username: 数据小黑 | Original post link

Have you switched databases using “use”? Where is the tidb_catalog catalog utilized?

| username: ShawU | Original post link

Switching databases, it seems that TiSpark currently does not support the SQL command INSERT SELECT?

| username: 数据小黑 | Original post link

Refer to: 关于TiSpark的几种使用方式以及常见错误 - TiDB 的问答社区