test_merge¶
The merge algebra: what combines from two partial answers, and what does not.
Each merge is checked against the same query run over the WHOLE table, which is the only assertion that means anything here – a merge that agrees with itself proves nothing. The refusals are tested as carefully as the successes, because an aggregate that combines wrongly answers confidently rather than failing.
Attributes¶
Classes¶
Functions¶
|
|
|
Per-key records from an ordered engine: a group CLOSES when the key |
|
|
|
|
|
|
|
|
|
|
|
|
|
An output that is an EXPRESSION over the aggregates is not an aggregate: |
The remedy the refusal names, tested: a mean asked for as an expression |
|
|
The hazard an ordered engine makes concrete: the group the boundary |
|
|
The conditional merge, checked rather than assumed. An ordered engine |
|
|
Each arm ascends, but the later arm reopens a key the earlier one |
The contrast with the ordered merge: an engine holding one accumulator |
|
|
Every row of the whole query's top k is in the top k of the range it |
|
The fixture's keys repeat, so the answer is decided by ties rather than |
|
|
|
Equal keys take the earlier range first, which is what keeps a stable |
|
|
|
|
The aggregate that looks additive and is not. |
|
|
|
|
Default-deny: an aggregate nobody has heard of is not added on the |
|
Whether a mean survives is a property of what the ENGINES emit, not |
|
A windowed result whose window spans the boundary reads rows from both |
The default is not a silent identity. A rule declared without a combine |
|
|
A degenerate share ran the whole query on one engine, so no merge is |
An engine that invalidated its own work returns a partial that says so. |
Module Contents¶
- test_merge.ROWS¶
- test_merge._totals(rows)¶
- test_merge._groups(rows)¶
Per-key records from an ordered engine: a group CLOSES when the key changes, which is what makes the boundary pair the only shared group.
- test_merge._stats(rows)¶
- test_merge._runs(rows)¶
- test_merge._halves(rows)¶
- test_merge.test_sums_and_counts_add() None¶
- test_merge.test_a_derived_output_is_recomputed_from_the_merged_totals() None¶
An output that is an EXPRESSION over the aggregates is not an aggregate: combining the arms’ ratios would produce a number that is not a ratio of anything, and it would look exactly like a total.
- test_merge.test_a_mean_survives_only_as_a_sum_and_a_count() None¶
The remedy the refusal names, tested: a mean asked for as an expression over two additive outputs splits exactly, while the mean of the arms’ means does not.
- test_merge.test_ordered_groups_fold_the_group_that_straddles_the_boundary() None¶
The hazard an ordered engine makes concrete: the group the boundary lands inside closes in BOTH arms, and the merge has to fold those two partial records rather than emit the key twice.
- test_merge.test_boundary_stats_come_from_the_ranges_that_own_them() None¶
firstandlastare defined by position, which is why the arms’ order is part of the contract: the straddling group opens in the earlier range and closes in the later one.
- test_merge.test_unsorted_rows_refuse_the_ordered_merge() None¶
The conditional merge, checked rather than assumed. An ordered engine closes a group when the key changes, so on unsorted rows it emits several records per key – merging those by key would collapse them into an answer no run produced.
- test_merge.test_arms_that_arrive_out_of_order_refuse_the_ordered_merge() None¶
Each arm ascends, but the later arm reopens a key the earlier one closed – so the two do not meet on one boundary key and the fold is not the merge this is.
- test_merge.test_keyed_groups_merge_over_the_whole_key_set() None¶
The contrast with the ordered merge: an engine holding one accumulator per distinct key can meet a key anywhere, so a key appears in both arms and there is no boundary pair.
- test_merge.test_a_top_k_merges_two_k_lists() None¶
Every row of the whole query’s top k is in the top k of the range it arrived in, so the two k-lists are the complete candidate set.
- test_merge.test_a_merged_top_k_keeps_the_earliest_arrival_tie_break() None¶
The fixture’s keys repeat, so the answer is decided by ties rather than by keys alone: a stable re-rank with the leading range first keeps earliest-arrival ties true of the whole table.
- test_merge.test_a_negative_limit_is_refused() None¶
- test_merge.test_sorted_runs_merge_stably() None¶
Equal keys take the earlier range first, which is what keeps a stable sort’s arrival-order ties true of the whole table rather than of each half.
- test_merge.test_an_empty_merge_answers() None¶
- test_merge._reductions(mergeable=ADDITIVE) dau_scheduler.MergeRule¶
- test_merge.test_check_split_refuses_a_mean_by_name() None¶
The aggregate that looks additive and is not.
- test_merge.test_check_split_refuses_a_distinct_count_by_name() None¶
- test_merge.test_the_order_statistics_and_moments_are_refused_by_name(kind: str) None¶
- test_merge.test_an_unknown_aggregate_is_refused_rather_than_summed() None¶
Default-deny: an aggregate nobody has heard of is not added on the assumption that every aggregate is additive.
- test_merge.test_a_declared_mean_passes_when_the_partials_carry_it() None¶
Whether a mean survives is a property of what the ENGINES emit, not something the merge step can recover – so a caller whose partials carry sum and count separately says so, and the check believes it.
- test_merge.test_boundary_stats_are_declarable_too() None¶
- test_merge.test_a_shape_that_cannot_split_refuses_before_any_aggregate() None¶
A windowed result whose window spans the boundary reads rows from both ranges, so no aggregate list makes it mergeable.
- test_merge.test_a_rule_with_no_combine_says_so() None¶
The default is not a silent identity. A rule declared without a combine step has nothing to reassemble partials with, and saying that beats returning one arm’s answer.
- test_merge.test_one_partial_is_the_answer() None¶
A degenerate share ran the whole query on one engine, so no merge is involved and none is attempted.
- test_merge.test_a_failed_arm_is_not_merged_into_a_short_answer() None¶
An engine that invalidated its own work returns a partial that says so. Merging that into the other arm’s would produce a plausible answer missing half the rows, so the failure is what reaches the caller.