Skip to content

Glue: honor Segment in get_partitions - #10123

Open
parisni wants to merge 2 commits into
getmoto:masterfrom
leboncoin:pr/glue-segmented-partitions
Open

Glue: honor Segment in get_partitions#10123
parisni wants to merge 2 commits into
getmoto:masterfrom
leboncoin:pr/glue-segmented-partitions

Conversation

@parisni

@parisni parisni commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

A segmented GetPartitions (the Segment parameter, {SegmentNumber, TotalSegments}) is used by parallel scanners such as the Hive metastore Glue
client. Per the API contract each segment must return a disjoint slice of the
partitions, and the union across all segments is the full set with no
duplicates.

moto currently ignores Segment and returns every partition for every segment,
so a client issuing TotalSegments=N sees each partition N times. When Spark
reads a partitioned table backed by the moto Glue catalog this multiplies every
row by N.

This assigns each partition to exactly one segment via a stable md5 hash of its
values, mirroring real AWS Glue segmentation.

Test added in tests/test_glue/test_datacatalog.py.

parisni and others added 2 commits July 20, 2026 17:06
A segmented GetPartitions (used by the SDK-v1 Hive metastore Glue client for
parallel partition scans) must return a disjoint slice per segment whose union
is the full set with no duplicates. moto ignored the Segment parameter and
returned every partition for each segment, so a client issuing TotalSegments=N
saw each partition N times. This made Spark read every partitioned table row
N times when reading a Delta/Hudi table synced into the moto Glue catalog.

Assign each partition to exactly one segment via a stable md5 hash of its
values, mirroring real AWS Glue segmentation semantics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants