Refactor: Consolidate schema inference (Phase 3)#16
Merged
Conversation
Extract common patterns from execute_remote, execute_virtualizarr, and execute_virtualizarr_with_adapter into shared helpers: - build_exec_projected_schema(): Common schema projection logic - AsyncReadParams: Encapsulates common async read parameters - execute_async_read(): Generic async execution with store setup closure This consolidates the repeated stream creation pattern: 1. Build projected schema 2. Create async stream with store setup 3. Call read_zarr_async 4. Collect batches and wrap in RecordBatchStreamAdapter Impact: -17 lines (132 additions, 149 deletions) with clearer separation of concerns. Each execute function now focuses only on its unique store setup logic. Part of: #5
Extract the duplicated schema building logic from three functions into a single `build_schema_from_store_meta()` helper: - infer_schema_from_zmetadata_json - infer_schema_with_meta - infer_schema_with_meta_async All three had identical logic for: 1. Building Dictionary-encoded coordinate fields (with CF time support) 2. Building regular array fields for data variables The helper centralizes this logic, making future schema changes easier to maintain consistently. Impact: -50 lines (57 additions, 107 deletions) Part of: #5
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
Phase 3 of refactoring to eliminate duplicated code. This builds on Phase 1 (#13) and Phase 2 (#15).
Note: This PR includes Phase 1 and Phase 2 commits. After those PRs are merged, this PR will auto-update to show only Phase 3 changes.
Phase 3 Changes
Extract the duplicated schema building logic from three functions into a single
build_schema_from_store_meta()helper:infer_schema_from_zmetadata_jsoninfer_schema_with_metainfer_schema_with_meta_asyncAll three had identical logic for:
The helper centralizes this logic, making future schema changes easier to maintain consistently.
Impact
Test plan
cargo test- All tests passcargo clippy- No warningscargo fmt- Properly formattedDepends on: #13 (Phase 1), #15 (Phase 2)
Part of #5