prestodb/presto · error · PrestoException

ALREADY_EXISTS

ALREADY_EXISTS

Error message

Partition already exists

What it means

doCreateEmptyPartition checks the metastore before writing; this fires when the requested partition already exists in the Hive metastore and the procedure was invoked without IF NOT EXISTS semantics, so creating an empty duplicate partition is refused.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/CreateEmptyPartitionProcedure.java:136

        List<String> partitionStringValues = partitionValues.stream()
                .map(String.class::cast)
                .collect(toImmutableList());

        if (metastore.getPartition(new MetastoreContext(
                        session.getIdentity(),
                        session.getQueryId(),
                        session.getClientInfo(),
                        session.getClientTags(),
                        session.getSource(),
                        getMetastoreHeaders(session),
                        false,
                        HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER,
                        session.getWarningCollector(),
                        session.getRuntimeStats()),
                schema,
                table,
                partitionStringValues).isPresent()) {
            throw new PrestoException(ALREADY_EXISTS, "Partition already exists");
        }
        String partitionName = FileUtils.makePartName(actualPartitionColumnNames, partitionStringValues);

        WriteInfo writeInfo = locationService.getPartitionWriteInfo(hiveInsertTableHandle.getLocationHandle(), Optional.empty(), partitionName);
        PartitionUpdate partitionUpdate = new PartitionUpdate(
                partitionName,
                UpdateMode.NEW,
                writeInfo.getWritePath(),
                writeInfo.getTargetPath(),
                ImmutableList.of(),
                0,
                0,
                0,
                writeInfo.getWritePath().getName().matches("\\d+"));
        byte[] serializedPartitionUpdate;
        if (isOptimizedPartitionUpdateSerializationEnabled(session)) {
            serializedPartitionUpdate = serializeZstdCompressed(partitionUpdateSmileCodec, partitionUpdate);
        }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Drop the existing partition first if a fresh empty one is required
  2. Skip creation if the existing partition is acceptable
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-hive/src/main/java/com/facebook/presto/hive/CreateEmptyPartitionProcedure.java:136 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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