Repository navigation
fix: criteria, COUNTBLANK and a table answer over a range covering most of the sheet answer at once (#676) - #684
Merged
Merged
Conversation
…676) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st of the sheet answer at once (#676) A range reaching past the sheet is read sparse: the cells inside the sheet at their places, every other place blank. The COUNTIF family and COUNTBLANK count those blank places arithmetically. A table the cell's whole formula answers is checked from its shape before it is built, and answers #SPILL! unbuilt when it cannot spill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll-reads Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The next pass reads each table's reach to decide which tables a read calculates early; without it the cells were calculated, and their errors reported, in another order than before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
Review ledger (local
|
| Round | Head | Verdict | Notes |
|---|---|---|---|
| 1 | 2ca37fd | LGTM | — |
| own differential | 2ca37fd | finding | A table refused before it was built did not record its reach, so the next pass calculated another table early and the errors list came in another order (values unchanged). Fixed in the next commit: placeResult takes the refusal and sets the reach first; regression test added. Count restarts. |
| 2 | 4f3261c | LGTM | Old/new whole results compared over sparse aggregates, cross-sheet reads, loops, spill refusals and the settled order workbook: no difference. |
| 3 | 4f3261c | LGTM | SUMIF/AVERAGEIF with value ranges of another shape, criteria as a cell reference and an array, COUNTIFS/SUMIFS/AVERAGEIFS/MAXIFS over 200k-row ranges: old and new equal. Two consecutive LGTMs on an unchanged head. |
Merged without re-merging main (main had moved to c271efc): no file in common between git diff --name-only 4f3261c...origin/main and this PR's files, git merge-tree clean, every PR check green. After merging (edd1043): yarn typecheck and yarn test:engine pass on main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #676. #677 bounded the reads that skip blank cells; the reads that keep one entry per cell still listed a range's whole area. This change bounds three of them by the cells the sheet holds, as Excel bounds them by the used range:
COUNTIF,SUMIF,AVERAGEIF,COUNTIFS,SUMIFS,AVERAGEIFS,MAXIFS,MINIFS) tests the cells the sheet holds; when every criteria matches a blank, the blank cells past the sheet are counted arithmetically.=B2:D1048576,=1+B2:XFD1048576,=ABS(C2:D1048576)) is checked from its shape before it is built. Past the sheet's edge, or (for a table larger thanMAX_TABLE_CELLS) over a filled cell, it answers#SPILL!without being built, with the same reported error as before.How:
getSparseRangeValues(rangeReading.ts): a range reaching past the sheet is read as its cells inside the sheet, each read asgetRangeValuesKeepingBlanksreads it, at its place in reading order, plus the area's size. A range inside the sheet returns null and keeps the dense read. The per-cell read was lifted intocellReading, shared by both reads.sparseCells.ts(pure):blankCount,countMeetingAll,placesMeetingAll,placesMatchingWithValues. A handler takes the sparse path only when one of its ranges is sparse; when all are dense the code it ran before runs unchanged.spillRefusal.ts(pure) andhugeTableAnswer.ts:EvaluatorContext.refusesTableis set only on the context of a cell's top-level evaluation (calculator.tsevaluateAnswer) and asked by the sole-range branch ofevaluateFormulaand byevaluateOverTables. When it refuses, the first element and the ranges' cells inside the sheet are read first, so loops through them are still found (=1+A1:D1048576in B1 is still#REF!).Items to Confirm / Review
INDIRECT("A"&ROW(B1:B9))) reached only by another element is no longer read. For a table that would have spilled past the edge this changes nothing unless such a read closes a loop.=ABS(Sheet2!A1:XFD1)in B1). The taken-cell check before building is only for tables larger thanMAX_TABLE_CELLS, because listing the taken cells costs a pass over the sheet; a smaller table is still checked when placed.getSparseRangeValuesonFunctionContext/EvaluatorContext,refusesTableonEvaluatorContext.getRangeGridstill lists a huge area (D-functions, TRANSPOSE, SORT, …): its callers need every position, and a D-function's computed criteria is evaluated per record, so blank records past the sheet are not alike. A huge table nested in a function (=SUM(1+B2:D1048576)), or a huge table that fits and spills (as Excel spills it), is still built element by element.Verification
yarn format && yarn lint && yarn build && yarn typecheck && yarn test && yarn test:engine && yarn test:fixtures && yarn quality, chained withset -e, passed before the push.tests/engine/test_sparseCells.tsandtest_spillRefusal.ts: the rules both ways (blank-matching criteria, mismatched sizes, empty inputs, a whole-sheet count under a time bound), plus generated ranges compared with counting over the dense list, and generated tables compared with listing every cellspillTargetscovers.tests/engine/test_hugeRangeReads.ts: COUNTBLANK, COUNTIF, SUMIF, AVERAGEIF, COUNTIFS, SUMIFS, AVERAGEIFS, MAXIFS over areas toXFD1048576, mismatched sizes, a loop through the formula's cell, and refused tables (past the edge, over a filled cell with its reported error, through a loop), each with a 10 s timeout. The engine at main runs out of heap on this file.=1+A1:D1048576118 s → 9 ms (#REF!),=1+C2:D104857616 s → 7 ms,=-Sheet2!A1:B104857618 s → 10 ms,=COUNTIF(A1:C1048576,"")1.8 s → 10 ms, other criteria and COUNTBLANK about 0.5 s → 10 ms. OverXFD-wide areas=COUNTIF(B2:XFD1048576,""),=COUNTBLANK(C2:XFD1048576)and=1+B2:XFD1048576ran out of memory on main and answer in under 10 ms. (Measured atdcc80dbvs this branch on a loaded machine; ratios, not absolutes.)calculateWorkbookresults compared (old tree copied from main before the change):Pinned: old =
dcc80db(main), new =4f3261c. Each seed's workbook is generated, calculated by both trees, and data, errors, circularLoops and spills are compared whole.4f3261cand pinned by a regression test intest_hugeRangeReads.ts.=A3:B4:C1048576+1), which is out of scope. Under load a few time out on one side only, and those are not compared.User Prompt
AI時代のスプレッドシートとしてExcelやGoogle Sheetsを超えるよう、Codexと並列で改善を続けて
work in GUIChatPluginSpreadsheet
🤖 Generated with Claude Code