{"record":{"id":"1ad4e875340c1fd1","repo":"prestodb/presto","slug":"hive-metastore-error","errorCode":"HIVE_METASTORE_ERROR","errorMessage":"currentStatistics is null","messagePattern":"currentStatistics is null","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java","lineNumber":961,"sourceCode":"        MetastoreContext metastoreContext = new MetastoreContext(\n                session.getIdentity(),\n                session.getQueryId(),\n                session.getClientInfo(),\n                session.getClientTags(),\n                session.getSource(),\n                getMetastoreHeaders(session),\n                isUserDefinedTypeEncodingEnabled(session),\n                columnConverterProvider,\n                session.getWarningCollector(),\n                session.getRuntimeStats());\n\n        if (oldPartitionAction == null) {\n            Partition partition = delegate.getPartition(metastoreContext, databaseName, tableName, partitionValues)\n                    .orElseThrow(() -> new PartitionNotFoundException(schemaTableName, partitionValues));\n            String partitionName = getPartitionName(metastoreContext, databaseName, tableName, partitionValues);\n            PartitionStatistics currentStatistics = delegate.getPartitionStatistics(metastoreContext, databaseName, tableName, ImmutableSet.of(partitionName)).get(partitionName);\n            if (currentStatistics == null) {\n                throw new PrestoException(HIVE_METASTORE_ERROR, \"currentStatistics is null\");\n            }\n            HdfsContext context = new HdfsContext(session, databaseName, tableName, tablePath, false);\n            partitionActionsOfTable.put(\n                    partitionValues,\n                    new Action<>(\n                            ActionType.INSERT_EXISTING,\n                            new PartitionAndMore(\n                                    partition,\n                                    currentLocation,\n                                    Optional.of(fileNames),\n                                    merge(currentStatistics, statisticsUpdate),\n                                    statisticsUpdate),\n                            context));\n            return;\n        }\n\n        switch (oldPartitionAction.getType()) {\n            case DROP:","sourceCodeStart":943,"sourceCodeEnd":979,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java#L943-L979","documentation":"An internal invariant check during partition add/alter: the existing partition's statistics object (currentStatistics) is unexpectedly null when computing the new partition state, indicating a coding/consistency defect rather than user error; it is raised via checkNotNull-style validation.","triggerScenarios":"Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/SemiTransactionalHiveMetastore.java:961 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Report as a bug with the query plan and operation sequence that triggered it","Work around by recreating the affected partition so its metadata (including statistics) is regenerated","Check the metastore partition metadata for null/missing statistics fields"],"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"}