prestodb/presto · error · PrestoException
HIVE_INVALID_METADATA
HIVE_INVALID_METADATA
Error message
Table '%s' or partition '%s' has null columns
What it means
Schema validation during split computation: either the table's dataColumns or the partition's columns list is null in the metastore. Presto requires both column lists to build a TableToPartitionMapping, so it throws HIVE_INVALID_METADATA — the Hive metadata itself is corrupt/incomplete.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveSplitManager.java:633
if (partitionsNotReadable.size() <= 3) {
partitionsNotReadable.putIfAbsent(reason, new HashSet<>(ImmutableSet.of(partitionName)));
if (partitionsNotReadable.get(reason).size() <= 3) {
partitionsNotReadable.get(reason).add(partitionName);
}
}
continue;
}
}
// Verify that the partition schema matches the table schema.
// Either adding or dropping columns from the end of the table
// without modifying existing partitions is allowed, but every
// column that exists in both the table and partition must have
// the same type.
List<Column> tableColumns = table.getDataColumns();
List<Column> partitionColumns = partition.getColumns();
if ((tableColumns == null) || (partitionColumns == null)) {
throw new PrestoException(HIVE_INVALID_METADATA, format("Table '%s' or partition '%s' has null columns", tableName, partitionName));
}
TableToPartitionMapping tableToPartitionMapping = getTableToPartitionMapping(session, resolvedHiveStorageFormat, tableName, partitionName, tableColumns, partitionColumns);
if (hiveBucketHandle.isPresent() && !hiveBucketHandle.get().isVirtuallyBucketed()) {
Optional<HiveBucketProperty> partitionBucketProperty = partition.getStorage().getBucketProperty();
if (!partitionBucketProperty.isPresent()) {
throw new PrestoException(HIVE_PARTITION_SCHEMA_MISMATCH, format(
"Hive table (%s) is bucketed but partition (%s) is not bucketed",
hivePartition.getTableName(),
hivePartition.getPartitionId().getPartitionName()));
}
int tableBucketCount = hiveBucketHandle.get().getTableBucketCount();
int partitionBucketCount = partitionBucketProperty.get().getBucketCount();
List<String> tableBucketColumns = hiveBucketHandle.get().getColumns().stream()
.map(HiveColumnHandle::getName)
.collect(toImmutableList());
List<String> partitionBucketColumns = partitionBucketProperty.get().getBucketedBy();
if (!tableBucketColumns.equals(partitionBucketColumns) || !isBucketCountCompatible(tableBucketCount, partitionBucketCount)) {View on GitHub (pinned to 55bb57d202)
Solutions
- Run MSCK REPAIR TABLE or use ALTER TABLE ADD/DROP COLUMNS to restore column metadata.
- Inspect the offending partition's metadata in the metastore (describe formatted <table> partition (...)) and recreate the partition with correct schema.
- Recreate the table/partition via Presto or Hive with a proper schema.
- Check for external writers or manual metastore edits that produced null columns.
Example fix
// before ALTER TABLE t ADD IF NOT EXISTS PARTITION (dt='2026-09-01'); -- metadata written with null columns by external tool // after ALTER TABLE t ADD IF NOT EXISTS PARTITION (dt='2026-09-01') LOCATION '...'; -- created via Hive/Presto so column schema is populated
Defensive patterns
Strategy: validation
Validate before calling
// pre-check via metastore client
Table t = metastore.getTable(db, name);
if (t.getSd().getCols() == null) { repairTableMetadata(); }
// or in SQL first: DESCRIBE <table>; verify columns non-empty Try / catch
catch (PrestoException e) { if (e.getErrorCode().getCode() == HIVE_INVALID_METADATA.toErrorCode().getCode()) { /* repair metadata then retry */ } else throw e; } Prevention
- Create partitions only through Hive/Presto or writers that populate column schemas.
- Run MSCK REPAIR TABLE / schema checks after external ETL writes.
- Audit metastore integrity after restores or manual edits.
When it happens
Trigger: computePartitionMetadata reads table.getDataColumns() or partition.getColumns() and gets null, typically because the metastore (or a direct thrift response) has a partition/table row with no SDS/column metadata.
Common situations: Partitions created by external tools that wrote incomplete metadata; metastore DB corruption or manual row edits; restore from backup missing column-schema rows.
Related errors
- HIVE_INVALID_METADATA
- HIVE_INVALID_METADATA
- SCHEMA_NOT_EMPTY
- Table not found: ${databaseName}.${tableName}
- ARROW_FLIGHT_METADATA_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/062483ef0ff58fea.
Report an issue: GitHub.