WIP: Google Sheets: auto-pad col_types when column count changes#1479
Open
WIP: Google Sheets: auto-pad col_types when column count changes#1479
Conversation
When a Google Sheet has more columns than specified in col_types, automatically pad with '?' (guess/default) for the extra columns instead of failing with "Length of col_types is not compatible" error. This fixes issues where: - User imports Google Sheet with column types specified - Additional columns are added to the sheet later - On refresh (Desktop or Server), the data source now succeeds with the new columns using automatic type detection Fixes exploratory-io/tam#33700 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Google Sheets refresh robustness by automatically handling col_types/column-count mismatches when a sheet gains new columns.
Changes:
- Add
.pad_col_types_for_column_mismatch()to extendcol_typeswith?based on the column count parsed from the googlesheets4 error message. - Add
.read_sheet_with_col_types_padding()wrapper to retrygooglesheets4::read_sheet()after padding on the specific mismatch error. - Add unit tests for the padding helper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
R/google_sheets.R |
Adds internal helpers and routes getGoogleSheet() reads through retry-with-padding logic to avoid failures when column counts increase. |
tests/testthat/test_google_sheets.R |
Adds unit coverage for the col_types padding helper behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
col_typeswith?(guess/default) when Google Sheet has more columns than specifiedProblem
When a Google Sheet's column structure changes (columns are added) after initial import, refreshing the data source fails with:
Solution
Instead of failing, the system now:
?for extra columnsTest plan
🤖 Generated with Claude Code