fix(file-based): support multi-sheet Excel workbooks via sheet_name config#1051
Draft
devin-ai-integration[bot] wants to merge 2 commits into
Draft
fix(file-based): support multi-sheet Excel workbooks via sheet_name config#1051devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
…onfig Add an optional sheet_name field to ExcelFormat config that controls which worksheet(s) the parser reads: - '0' (default): first sheet only (preserves existing behavior) - '<name>': a specific sheet by name - '*': all sheets in the workbook Both Calamine and OpenPyXL fallback paths now pass sheet_name through to pandas. Schema inference merges columns across selected sheets. Co-Authored-By: bot_apk <apk@cognition.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1781264638-fix-excel-multisheet#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1781264638-fix-excel-multisheetPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Co-Authored-By: bot_apk <apk@cognition.ai>
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
The file-based CDK Excel parser previously relied on the pandas default
sheet_name=0, so only the first worksheet was ever read from multi-sheet workbooks. This caused silent data loss for connectors like source-microsoft-sharepoint when users had Excel files with multiple sheets.This PR adds an optional
sheet_namefield toExcelFormat:Accepted values:
"0"(default, first sheet — preserves existing behavior), a sheet name string, a zero-indexed position, or"*"to read all sheets.The new
_parse_excel_file→_resolve_sheet_namepath converts the string config into a pandas-compatiblesheet_nameargument (int,str, orNone). Whensheet_name=None(all sheets), pandas returns adict[str, DataFrame]instead of a singleDataFrame; the parser iterates over all returned DataFrames for both record emission and schema inference (merging columns across sheets).Both Calamine-first and OpenPyXL fallback paths now accept and forward the
sheet_nameparameter.Resolves https://github.com/airbytehq/oncall/issues/12598:
Supersedes #1024 (stale draft from a prior session).
Declarative-First Evaluation
The affected connectors (source-microsoft-sharepoint, etc.) are Python file-based CDK sources, not manifest-only connectors. The fix operates at the Excel parsing layer before any records exist, so declarative features (
RecordFilter,AddFields,RemoveFields, paginators, routers, error handlers,$refoverrides) cannot address this.Breaking Change Evaluation
Not a breaking change. The new
sheet_namefield is optional and defaults to"0", preserving the previous first-sheet-only behavior. No streams, fields, primary keys, cursors, existing config fields, or state formats are removed or changed.Test Coverage
New tests added to
test_excel_parser.py:test_parse_records_selects_configured_sheet— parametrized for default first sheet, named sheet, and all sheetstest_infer_schema_with_sheet_selection— parametrized for single-sheet and merged multi-sheet schema inferencetest_resolve_sheet_name— parametrized unit test for the config → pandas argument conversionAll tests use real in-memory multi-sheet Excel workbooks (via xlsxwriter) instead of mocks.
Link to Devin session: https://app.devin.ai/sessions/6a77303e47e040da803aeee819febb5b