{"record":{"id":"91d19093b2813b3c","repo":"prestodb/presto","slug":"already-exists-91d190","errorCode":"ALREADY_EXISTS","errorMessage":"Partition already exists","messagePattern":"Partition already exists","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/CreateEmptyPartitionProcedure.java","lineNumber":136,"sourceCode":"        List<String> partitionStringValues = partitionValues.stream()\n                .map(String.class::cast)\n                .collect(toImmutableList());\n\n        if (metastore.getPartition(new MetastoreContext(\n                        session.getIdentity(),\n                        session.getQueryId(),\n                        session.getClientInfo(),\n                        session.getClientTags(),\n                        session.getSource(),\n                        getMetastoreHeaders(session),\n                        false,\n                        HiveColumnConverterProvider.DEFAULT_COLUMN_CONVERTER_PROVIDER,\n                        session.getWarningCollector(),\n                        session.getRuntimeStats()),\n                schema,\n                table,\n                partitionStringValues).isPresent()) {\n            throw new PrestoException(ALREADY_EXISTS, \"Partition already exists\");\n        }\n        String partitionName = FileUtils.makePartName(actualPartitionColumnNames, partitionStringValues);\n\n        WriteInfo writeInfo = locationService.getPartitionWriteInfo(hiveInsertTableHandle.getLocationHandle(), Optional.empty(), partitionName);\n        PartitionUpdate partitionUpdate = new PartitionUpdate(\n                partitionName,\n                UpdateMode.NEW,\n                writeInfo.getWritePath(),\n                writeInfo.getTargetPath(),\n                ImmutableList.of(),\n                0,\n                0,\n                0,\n                writeInfo.getWritePath().getName().matches(\"\\\\d+\"));\n        byte[] serializedPartitionUpdate;\n        if (isOptimizedPartitionUpdateSerializationEnabled(session)) {\n            serializedPartitionUpdate = serializeZstdCompressed(partitionUpdateSmileCodec, partitionUpdate);\n        }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/CreateEmptyPartitionProcedure.java#L118-L154","documentation":"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.","triggerScenarios":"Thrown at presto-hive/src/main/java/com/facebook/presto/hive/CreateEmptyPartitionProcedure.java:136 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Drop the existing partition first if a fresh empty one is required","Skip creation if the existing partition is acceptable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}