{"record":{"id":"b95204e71f95ae2c","repo":"prestodb/presto","slug":"hive-partition-schema-mismatch-b95204","errorCode":"HIVE_PARTITION_SCHEMA_MISMATCH","errorMessage":"There is a mismatch between the table and partition schemas. The column '%s' in table '%s.%s' is declared as type '%s', but partition '%s' declared column '%s' as type '%s'.","messagePattern":"There is a mismatch between the table and partition schemas\\. The column '(.+?)' in table '(.+?)\\.(.+?)' is declared as type '(.+?)', but partition '(.+?)' declared column '(.+?)' as type '(.+?)'\\.","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveWriterFactory.java","lineNumber":595,"sourceCode":"        }\n        if (fileColumnNames.size() != fileColumnHiveTypes.size()) {\n            throw new PrestoException(HIVE_INVALID_METADATA, format(\n                    \"Partition '%s' in table '%s.%s' has mismatched metadata for column names and types\",\n                    partitionName,\n                    schemaName,\n                    tableName));\n        }\n\n        // verify the file types match the input type\n        // todo adapt input types to the file types as Hive does\n        for (int fileIndex = 0; fileIndex < fileColumnNames.size(); fileIndex++) {\n            String columnName = fileColumnNames.get(fileIndex);\n            HiveType fileColumnHiveType = fileColumnHiveTypes.get(fileIndex);\n            HiveType inputHiveType = inputColumnMap.get(columnName).getHiveType();\n\n            if (!fileColumnHiveType.equals(inputHiveType)) {\n                // todo this should be moved to a helper\n                throw new PrestoException(HIVE_PARTITION_SCHEMA_MISMATCH, format(\n                        \"\" +\n                                \"There is a mismatch between the table and partition schemas. \" +\n                                \"The column '%s' in table '%s.%s' is declared as type '%s', \" +\n                                \"but partition '%s' declared column '%s' as type '%s'.\",\n                        columnName,\n                        schemaName,\n                        tableName,\n                        inputHiveType,\n                        partitionName,\n                        columnName,\n                        fileColumnHiveType));\n            }\n        }\n    }\n\n    private Consumer<HiveWriter> createCommitEventListener(\n            Path path,\n            Optional<String> partitionName,","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveWriterFactory.java#L577-L613","documentation":"Error \"There is a mismatch between the table and partition schemas. The column '%s' in table '%s.%s' is declared as type '%s', but partition '%s' declared column '%s' as type '%s'.\" thrown in prestodb/presto.","triggerScenarios":"Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveWriterFactory.java:595 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the partition metadata via ALTER or by recreating the partition so its column type matches the table","Drop and re-create the partition with consistent types","Cast data during a rewrite to reconcile types"],"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"}