Skip to content

Use Hive sentinel bucket count for unbucketed thrift tables#28798

Merged
dain merged 1 commit intomasterfrom
user/dain/thrift-num-buckets-sentinel
Mar 25, 2026
Merged

Use Hive sentinel bucket count for unbucketed thrift tables#28798
dain merged 1 commit intomasterfrom
user/dain/thrift-num-buckets-sentinel

Conversation

@dain
Copy link
Copy Markdown
Member

@dain dain commented Mar 22, 2026

Description

Set the Hive thrift StorageDescriptor.numBuckets field to -1 for
unbucketed tables created by Trino.

Hive uses -1 as the sentinel value for "not bucketed". Leaving the
thrift default of 0 can lead to divergent behavior for unbucketed
tables 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 = 0 for
unbucketed tables, but Apache Hive 3.1 treats that differently from the
expected -1 sentinel value. This change aligns Trino's thrift
serialization with Hive's expected contract without changing bucketed
table behavior.

Apache Hive itself uses -1 for this case, for example in:

Release notes

(x) Release notes are required, with the following suggested text:

## Hive
* Fix creation of unbucketed Hive tables in HMS for Apache Hive 3.1.

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.
@cla-bot cla-bot bot added the cla-signed label Mar 22, 2026
@github-actions github-actions bot added the hive Hive connector label Mar 22, 2026
@dain dain requested a review from electrum March 25, 2026 17:19
@dain dain merged commit 6c2b98e into master Mar 25, 2026
73 checks passed
@dain dain deleted the user/dain/thrift-num-buckets-sentinel branch March 25, 2026 17:19
@github-actions github-actions bot added this to the 481 milestone Mar 25, 2026
@ebyhr ebyhr mentioned this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed hive Hive connector

Development

Successfully merging this pull request may close these issues.

3 participants