Use Hive sentinel bucket count for unbucketed thrift tables#28798
Merged
Use Hive sentinel bucket count for unbucketed thrift tables#28798
Conversation
Hive uses -1 as the Thrift metastore sentinel value for tables that are not bucketed. Leaving the StorageDescriptor default of 0 can lead to divergent behavior for unbucketed tables created by Trino. Set numBuckets to -1 before applying bucket properties, and add unit tests covering both the unbucketed sentinel case and the normal bucketed-table case.
ebyhr
approved these changes
Mar 23, 2026
wendigo
approved these changes
Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Set the Hive thrift
StorageDescriptor.numBucketsfield to-1forunbucketed tables created by Trino.
Hive uses
-1as the sentinel value for "not bucketed". Leaving thethrift default of
0can lead to divergent behavior for unbucketedtables created by Trino.
This change preserves the existing behavior for bucketed tables and adds
unit tests covering both cases.
Additional context and related issues
This issue was observed while testing against Apache Hive 3.1.
Some Hive distributions appear to tolerate
numBuckets = 0forunbucketed tables, but Apache Hive 3.1 treats that differently from the
expected
-1sentinel value. This change aligns Trino's thriftserialization with Hive's expected contract without changing bucketed
table behavior.
Apache Hive itself uses
-1for this case, for example in:Table.getEmptyTable()AlterTableNotClusteredOperationRelease notes
(x) Release notes are required, with the following suggested text: