prestodb/presto · error · PrestoException
HIVE_INVALID_METADATA
HIVE_INVALID_METADATA
Error message
SerDe is not present in StorageFormat
What it means
StorageFormat is an optional-container for serDe/inputFormat/outputFormat read from Hive storage descriptors. getSerDe() throws HIVE_INVALID_METADATA when the serDe field is null, meaning the table or partition's storage descriptor lacks a SerDe name — the metadata cannot describe how to serialize/deserialize the data, so reads/writes are impossible.
Source
Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/StorageFormat.java:48
public class StorageFormat
{
public static final StorageFormat VIEW_STORAGE_FORMAT = StorageFormat.createNullable(null, null, null);
private final String serDe;
private final String inputFormat;
private final String outputFormat;
private StorageFormat(String serDe, String inputFormat, String outputFormat)
{
this.serDe = serDe;
this.inputFormat = inputFormat;
this.outputFormat = outputFormat;
}
public String getSerDe()
{
if (serDe == null) {
throw new PrestoException(HIVE_INVALID_METADATA, "SerDe is not present in StorageFormat");
}
return serDe;
}
public String getInputFormat()
{
if (inputFormat == null) {
throw new PrestoException(HIVE_UNSUPPORTED_FORMAT, "InputFormat is not present in StorageFormat");
}
return inputFormat;
}
public String getOutputFormat()
{
if (outputFormat == null) {
throw new PrestoException(HIVE_UNSUPPORTED_FORMAT, "OutputFormat is not present in StorageFormat");
}
return outputFormat;View on GitHub (pinned to 55bb57d202)
Solutions
- Fix the table/partition metadata so the storage descriptor includes a valid SerDe (e.g. ALTER TABLE ... SET SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe')
- Drop and re-create the table/partition with a complete ROW FORMAT SERDE clause
- Restore the storage descriptor from metastore backup if corrupted
- If a partition was added manually, re-add it with MSCK or with full storage descriptor info
Example fix
// before (metadata without serde) CREATE EXTERNAL TABLE t (a int) STORED AS TEXTFILE LOCATION '...'; // after CREATE EXTERNAL TABLE t (a int) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' STORED AS TEXTFILE LOCATION '...';
Defensive patterns
Strategy: validation
Validate before calling
// Validate storage descriptor before querying the table via Thrift metastore
StorageDescriptor sd = table.getSd();
if (sd.getSerdeInfo() == null || sd.getSerdeInfo().getSerializationLib() == null) {
throw new IllegalStateException("table missing SerDe: " + table.getTableName());
} Type guard
boolean hasSerde(StorageFormat format) {
return format.getSerDeNullable() != null;
} Try / catch
try {
selectFrom(table);
} catch (PrestoException e) {
if (e.getErrorCode().getName().equals("HIVE_INVALID_METADATA")) {
// ALTER TABLE ... SET SERDE or recreate the table
}
throw e;
} Prevention
- Always specify ROW FORMAT SERDE / STORED AS when creating external tables
- Run MSCK REPAIR or full-partition adds rather than manual metastore inserts
- Audit metastore storage descriptors after migrations
- Use getSerDeNullable() to probe instead of getSerDe() when metadata may be incomplete
When it happens
Trigger: Querying or writing a table/partition whose metastore StorageDescriptor has no SerDe (null serDe in StorageFormat), typically from metadata written without a SerDe or stripped by another tool; getSerDe is called by serde(), fileContent(), createFileWriter(), etc.
Common situations: Tables created by external tools with incomplete storage descriptors; partitions added manually to the metastore without serde info; corrupted storage descriptors after migration; CREATE TABLE scripts omitting ROW FORMAT SERDE.
Related errors
- HIVE_UNSUPPORTED_FORMAT
- HIVE_SERDE_NOT_FOUND
- HIVE_SERDE_NOT_FOUND
- HIVE_UNSUPPORTED_FORMAT
- GENERIC_INTERNAL_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/f30a649681a9f020.
Report an issue: GitHub.