dataengref errors

Home / Hive / Partitions

Hive: SemanticException [Error 10044]: Cannot insert into target table because column number/types are different

org.apache.hadoop.hive.ql.parse.SemanticExceptionCannot insert into target table because column number/types are different

The SELECT feeding an INSERT returns a different number of columns, or incompatible types, than the target table expects. With dynamic partitions, the partition columns count as part of the SELECT.

Causes · Fixes · Source

Common causes

  1. The SELECT has one column too many or too few, often after a column was added to the target table.How to confirm: Compare DESCRIBE target with the SELECT list, including partition columns.
  2. Dynamic partition columns are missing from the end of the SELECT, or listed in PARTITION (...) with values and again in the SELECT.How to confirm: The message names the target table and the column counts.

How to fix it

List the target columns explicitly and make the SELECT match them, with partition columns last.

INSERT INTO TABLE sales PARTITION (dt)
SELECT order_id, amount, dt FROM staging;

Where the message comes from

References

Related errors

Last checked: