prestodb/presto · error · IllegalArgumentException

unexpected update mode:

Error message

unexpected update mode: 

What it means

An internal IllegalArgumentException raised while preparing partition updates for a write: the connector's UpdateMode enum (e.g. APPEND, NEW, OVERWRITE, INSERT_EXISTING) encountered a value it does not recognize in its switch statement. This indicates a connector-internal inconsistency or a newer write mode produced by a different code path/version than this switch handles, not a user input problem.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java:2446

                .collect(toImmutableList());
    }

    private Map<String, Optional<Partition>> getExistingPartitionsByNames(MetastoreContext metastoreContext, String databaseName, String tableName, List<PartitionUpdate> partitionUpdates)
    {
        ImmutableMap.Builder<String, Optional<Partition>> existingPartitions = ImmutableMap.builder();
        ImmutableSet.Builder<String> potentiallyNewPartitions = ImmutableSet.builder();

        for (PartitionUpdate update : partitionUpdates) {
            switch (update.getUpdateMode()) {
                case APPEND:
                    existingPartitions.put(update.getName(), Optional.empty());
                    break;
                case NEW:
                case OVERWRITE:
                    potentiallyNewPartitions.add(update.getName());
                    break;
                default:
                    throw new IllegalArgumentException("unexpected update mode: " + update.getUpdateMode());
            }
        }

        // try to load potentially new partitions in batches to check if any of them exist
        Lists.partition(ImmutableList.copyOf(potentiallyNewPartitions.build()), maxPartitionBatchSize).stream()
                .flatMap(partitionNames -> metastore.getPartitionsByNames(metastoreContext, databaseName, tableName, getPartitionNamesWithEmptyVersion(partitionNames)).entrySet().stream()
                        .filter(entry -> entry.getValue().isPresent()))
                .forEach(entry -> existingPartitions.put(entry.getKey(), entry.getValue()));

        return existingPartitions.build();
    }

    @Override
    public void createView(ConnectorSession session, ConnectorTableMetadata viewMetadata, String viewData, boolean replace)
    {
        MetastoreContext metastoreContext = getMetastoreContext(session);
        SchemaTableName viewName = viewMetadata.getTable();
        Table table = createTableObjectForViewCreation(

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Ensure all Presto nodes run the same version (no mixed coordinator/worker builds)
  2. Search the codebase for newly added UpdateMode constants and add a case for them in this switch
  3. Reproduce with a minimal query and file a bug with the update mode value
  4. As a workaround, downgrade/align to a single consistent release

Example fix

// before
default:
    throw new IllegalArgumentException("unexpected update mode: " + update.getUpdateMode());
// after
case INSERT_EXISTING:
    // handle the mode that was missing
    break;
default:
    throw new IllegalArgumentException("unexpected update mode: " + update.getUpdateMode());
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Calling HiveMetadata.finishInsert/applyDelta path where an update row carries an UpdateMode outside {APPEND, NEW, OVERWRITE, INSERT_EXISTING}; typically caused by version mismatch between engine/connector code or a new enum constant added without updating the switch.

Common situations: Mixed-version Presto coordinator/worker deployment where one side serializes an update mode the other doesn't know; custom patches adding an UpdateMode constant without updating all switches; corrupted internal state.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/8b5c9b40bfaf27ec. Report an issue: GitHub.