feat(google-sheets): add row filtering to read with numeric operators#4822
Conversation
Adds client-side row filtering to the Google Sheets read (v2) operation. Filter the returned rows by a header column using text operators (contains, not_contains, exact, not_equals, starts_with, ends_with) and numeric/ordering operators (gt, gte, lt, lte). Filtering lives in a pure, unit-tested helper (filterSheetRows) and runs over the fetched read range; an optional `filter` output reports whether the column was found and how many rows matched. Also hardens the surrounding tools: - trim spreadsheetId in write/update/append URL builders (matches read) - URL-encode the v1 read default range - expose valueInputOption for the update operation in the block Backwards compatible: with no filter requested, read output is byte- identical and the `filter` field is omitted. The filterMatchType union is widened additively (4 -> 10 values).
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview The Google Sheets v2 block UI and I/O docs mirror the new match types and Reviewed by Cursor Bugbot for commit 9866c0b. Configure here. |
Greptile SummaryThis PR adds client-side row filtering to the Google Sheets read (v2) operation, supporting both text operators (
Confidence Score: 5/5Safe to merge — the change is fully backwards compatible, filtering is isolated to a pure helper with good test coverage, and all URL builder hardening is defensive-only. The core filtering logic is correct and well-tested across all operators, edge cases (sparse rows, header-only sheets, empty arrays), and the two bugs caught in the prior review round are addressed. The encodeURIComponent and spreadsheetId?.trim() hardening changes are low-risk. No regressions to existing read behaviour. filter.ts has two minor correctness edges (early-return columnFound when filterValue is empty, and unpinned locale in compareLexicographic) that are benign for the current sole consumer but worth fixing before the function gains more callers. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[readV2Tool.transformResponse] --> B[Parse response JSON]
B --> C[rawValues = data.values ?? empty]
C --> D{filterRequested?\nfilterColumn + filterValue set?}
D -- No --> E[filterSheetRows returns\noriginal values unchanged]
D -- Yes --> F[filterSheetRows called\nwith filter options]
F --> G{filterColumn\nfound in header?}
G -- No --> H[Return original values\ncolumnFound=false, matchedRows=0]
G -- Yes --> I{values.length <= 1?\nheader-only / empty?}
I -- Yes --> J[Return original values\ncolumnFound=true, matchedRows=0]
I -- No --> K[Filter data rows\nvia matchesCell]
K --> L{matchType}
L -- gt/gte/lt/lte --> M{Both numeric?}
M -- Yes --> N[Numeric compare]
M -- Both non-numeric --> O[Lexicographic compare]
M -- Mixed --> P[No match - return false]
L -- text operators --> Q[Case-insensitive\nstring comparison]
K --> R[Return header + matched rows\napplied=true]
E --> S[Output: values only\nno filter field]
H --> T[Output: original values\n+ filter field with columnFound=false]
J --> T
R --> U[Output: filtered values\n+ filter field with applied=true]
Reviews (2): Last reviewed commit: "fix(google-sheets): correct filter metad..." | Re-trigger Greptile |
…ader-only sheets - matchedRows is now 0 (not totalRows) when the filter column is not found, so it no longer contradicts applied=false / columnFound=false - columnFound now reflects an actual header lookup for empty/header-only sheets instead of being hardcoded true - add tests covering header-only and empty sheets with present/absent columns
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9866c0b. Configure here.
Summary
filterSheetRows); adds an optionalfilteroutput reporting whether the column was found and how many rows matchedspreadsheetIdin write/update/append URL builders, URL-encode the v1 read default range, exposevalueInputOptionfor the update operationfilterfield is omittedType of Change
Testing
Checklist