prestodb/presto · error · PrestoException
HIVE_INVALID_METADATA
HIVE_INVALID_METADATA
Error message
Table/partition metadata has 'numBuckets' set, but 'bucketCols' is not set:
What it means
HiveBucketProperty.fromStorageDescriptor validates bucketing metadata read from the metastore: the StorageDescriptor declares numBuckets but bucketing column names (bucketCols) are absent or empty. This signals inconsistent table/partition metadata in the Hive metastore that Presto refuses to interpret.
Source
Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveBucketProperty.java:75
if (bucketFunctionType.equals(PRESTO_NATIVE)) {
checkArgument(types.isPresent(), "Types must be present for bucket function type " + bucketFunctionType);
checkArgument(types.get().size() == bucketedBy.size(), "The sizes of bucketedBy and types should match");
}
else {
checkArgument(!types.isPresent(), "Types not needed for bucket function type " + bucketFunctionType);
}
}
public static Optional<HiveBucketProperty> fromStorageDescriptor(StorageDescriptor storageDescriptor, String tablePartitionName)
{
boolean bucketColsSet = storageDescriptor.isSetBucketCols() && !storageDescriptor.getBucketCols().isEmpty();
boolean numBucketsSet = storageDescriptor.isSetNumBuckets() && storageDescriptor.getNumBuckets() > 0;
if (!numBucketsSet) {
// In Hive, a table is considered as not bucketed when its bucketCols is set but its numBucket is not set.
return Optional.empty();
}
if (!bucketColsSet) {
throw new PrestoException(HIVE_INVALID_METADATA, "Table/partition metadata has 'numBuckets' set, but 'bucketCols' is not set: " + tablePartitionName);
}
List<SortingColumn> sortedBy = ImmutableList.of();
if (storageDescriptor.isSetSortCols()) {
sortedBy = storageDescriptor.getSortCols().stream()
.map(order -> SortingColumn.fromMetastoreApiOrder(order, tablePartitionName))
.collect(toImmutableList());
}
return Optional.of(new HiveBucketProperty(
storageDescriptor.getBucketCols(),
storageDescriptor.getNumBuckets(),
sortedBy,
HIVE_COMPATIBLE,
Optional.empty()));
}
@JsonProperty
public List<String> getBucketedBy()
{View on GitHub (pinned to 55bb57d202)
Solutions
- Repair the table or partition metadata so bucketCols and numBuckets are consistent (recreate or ALTER the table if needed)
- Drop and re-add the affected partition with correct bucketing properties
- Check the tool or pipeline that wrote the metadata for a bug that persists numBuckets without bucketCols
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveBucketProperty.java:75 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/c28174bd92f579f2.
Report an issue: GitHub.