Expand description
Merge consecutive parquet partitions into a single file
Structs§
- Merge
Query Result - The outcome of running a merge query.
- Planned
Sorted Merge - A
PerFilemerge plan, built but not executed. - Query
Merger - A
PartitionMergerthat executes a SQL query to merge partitions.
Traits§
- Partition
Merger - A trait for merging partitions.
Functions§
- create_
merged_ partition - Creates a merged partition from a set of existing partitions.
- make_
merge_ session_ context - A merge is a bounded, streaming rewrite of a fixed set of files whose consumer is a single
writer task (
create_merged_partition->write_partition_from_rows), not a query that benefits from scan parallelism. Left at DataFusion’s default (true),EnsureRequirementssplits the source scan intotarget_partitionsbyte-range file groups andexecute_streamcoalesces them, so the reader working set is multiplied by the host’s core count for no throughput the writer can absorb. Forcing one sequential file group here fixes that for theUnorderedandConcatenatedshapes, which both start from a single file group spanning every input partition: left unsplit, one reader works through that group’s files one at a time instead oftarget_partitionsconcurrent byte-range readers.PerFilealready builds one file group per input partition, and this setting is load-bearing there too: left attrue,repartition_file_groups(viarepartition_preserving_order) splits each of those k per-partition groups intotarget_partitionsbyte-range groups whenever k <target_partitions, so this setting is what keepsPerFileat one reader per input file for its k-way ordered merge. Downstream parallelism is untouched: a merge query with a GROUP BY still gets its round-robin fan-out above the scan. - plan_
sorted_ merge - Builds the
PerFilek-way merge plan: four optimizer settings keep the merge a bounded-memory streaming k-way merge instead of fanning out totarget_partitions–repartition_file_scans = falseis the fifth, applied to every merge by the caller’smake_merge_session_contextsession rather than set here – an unconditional logical-planDataFrame::sortmakes the declared ordering a property of the query plan rather than of an optimizer preference (so a wrong or missing merge-query sort is not representable), and three checks – two hard, one reported throughordering_honored– run against the physical plan. Shared by the daemon’s merge and the admin streaming check so the two cannot drift.