Skip to content

Elementwise ops over a vertical range return a 1xN row instead of an Nx1 column (range half of #707) #724

Description

@hhimanshu

Summary

Elementwise operations over a vertical range lose column orientation: =A1:A3*2 (with A1:A3 vertical = 1,2,3) returns a 1×N row [[2,4,6]] instead of the N×1 column [[2],[4],[6]] Google Sheets produces — so it spills horizontally instead of down.

This is the range half of #707. The SEQUENCE/array-constructor half was fixed in #723; this range half was deliberately deferred because it's a larger change.

Why it's separate / harder

resolve_range (crates/workbook/src/recalc.rs) materializes every range as a flat row-major array, so a vertical range loses its orientation before core's eval ever sees it. A trial fix to make range materialization shape-aware broke 4 pinned conformance fixturesAVERAGE(Data!A1:A3)→#DIV/0!, SUMIF(Data!A1:A3,">15")→0, AVERAGE(PRICES)→#DIV/0!, MAX(PRICES)→#REF! — because core's aggregation/criteria helpers (flatten_to_vec, etc.) flatten only one level of a nested array.

What the real fix needs

  • Make range materialization shape-aware (a vertical range → N×1, horizontal → 1×N), AND
  • Make the aggregation/criteria helpers (flatten_to_vec and friends) fully flatten nested arrays so AVERAGE/SUM/SUMIF/MAX/etc. over a range still work.
  • Do it together so no fixture regresses.

Impact

=<vertical range> <op> <scalar> (e.g. =A1:A3*2, =A1:A3+1) spills horizontally instead of down, diverging from Sheets. Lower urgency than the SEQUENCE case (which #723 fixed and is the common one), but a real remaining divergence and the completion of #707.

Acceptance

  • =A1:A3*2 over a vertical range returns an N×1 column (spills down).
  • Aggregation/criteria over ranges (AVERAGE/SUM/SUMIF/MAX) unchanged — the 4 fixtures still pass.
  • No fixture regressions.

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions