dataengref errors

Home / Hive / Partitions

Hive: Number of dynamic partitions created is N, which is more than 1000

org.apache.hadoop.hive.ql.metadata.HiveExceptionFAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.exec.MoveTask. Number of dynamic partitions created is 1460, which is more than 1000. To solve this try to set hive.exec.max.dynamic.partitions to at least 1460.

Reproduced on Hive 4.2.1, · How

A dynamic-partition INSERT would create more partitions than hive.exec.max.dynamic.partitions (1000 by default). Before raising the limit, check whether the partition column is right: thousands of partitions from one insert often come from the wrong column order in the SELECT.

Causes · Fixes · Reproduce · Source

Common causes

  1. The partition columns are not the last columns of the SELECT, so a high-cardinality column such as an ID is used as the partition value.How to confirm: Run the SELECT alone and look at the values in the last columns; they should be the partition values.
  2. The insert genuinely spans many partitions, for example a backfill of several years of daily data.How to confirm: Count distinct partition values in the source: SELECT COUNT(DISTINCT dt) FROM source.

How to fix it

Put the partition columns last in the SELECT, in the same order as in PARTITION (...).

For real backfills, raise the total and per-node limits, or load in smaller date ranges.

SettingDefaultNote
hive.exec.max.dynamic.partitions1000
hive.exec.max.dynamic.partitions.pernode100

Reproduce it

Triggered on Hive 4.2.1 in a local Docker container, using the SQL client:

SET hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions=2;
CREATE TABLE IF NOT EXISTS repro_parts (v INT) PARTITIONED BY (dt STRING);
INSERT INTO repro_parts PARTITION (dt) SELECT 1, d FROM (SELECT '2025-01-01' AS d UNION ALL SELECT '2025-01-02' AS d UNION ALL SELECT '2025-01-03' AS d) s;

Output:

Error: Error while compiling statement: FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.exec.MoveTask. Number of dynamic partitions created is 3, which is more than 2. To solve this try to set hive.exec.max.dynamic.partitions to at least 3.

Where the message comes from

Message template in the source: Number of dynamic partitions created is %d, which is more than %d. To solve this try to set hive.exec.max.dynamic.partitions to at least %d.

References

Related errors

Last checked: