{"record":{"id":"c28174bd92f579f2","repo":"prestodb/presto","slug":"hive-invalid-metadata-c28174","errorCode":"HIVE_INVALID_METADATA","errorMessage":"Table/partition metadata has 'numBuckets' set, but 'bucketCols' is not set: ","messagePattern":"Table/partition metadata has 'numBuckets' set, but 'bucketCols' is not set: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveBucketProperty.java","lineNumber":75,"sourceCode":"        if (bucketFunctionType.equals(PRESTO_NATIVE)) {\n            checkArgument(types.isPresent(), \"Types must be present for bucket function type \" + bucketFunctionType);\n            checkArgument(types.get().size() == bucketedBy.size(), \"The sizes of bucketedBy and types should match\");\n        }\n        else {\n            checkArgument(!types.isPresent(), \"Types not needed for bucket function type \" + bucketFunctionType);\n        }\n    }\n\n    public static Optional<HiveBucketProperty> fromStorageDescriptor(StorageDescriptor storageDescriptor, String tablePartitionName)\n    {\n        boolean bucketColsSet = storageDescriptor.isSetBucketCols() && !storageDescriptor.getBucketCols().isEmpty();\n        boolean numBucketsSet = storageDescriptor.isSetNumBuckets() && storageDescriptor.getNumBuckets() > 0;\n        if (!numBucketsSet) {\n            // In Hive, a table is considered as not bucketed when its bucketCols is set but its numBucket is not set.\n            return Optional.empty();\n        }\n        if (!bucketColsSet) {\n            throw new PrestoException(HIVE_INVALID_METADATA, \"Table/partition metadata has 'numBuckets' set, but 'bucketCols' is not set: \" + tablePartitionName);\n        }\n        List<SortingColumn> sortedBy = ImmutableList.of();\n        if (storageDescriptor.isSetSortCols()) {\n            sortedBy = storageDescriptor.getSortCols().stream()\n                    .map(order -> SortingColumn.fromMetastoreApiOrder(order, tablePartitionName))\n                    .collect(toImmutableList());\n        }\n        return Optional.of(new HiveBucketProperty(\n                storageDescriptor.getBucketCols(),\n                storageDescriptor.getNumBuckets(),\n                sortedBy,\n                HIVE_COMPATIBLE,\n                Optional.empty()));\n    }\n\n    @JsonProperty\n    public List<String> getBucketedBy()\n    {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveBucketProperty.java#L57-L93","documentation":"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.","triggerScenarios":"Thrown at presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveBucketProperty.java:75 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}