refactor(context): deduplicate register/read option-building logic#1479
Open
mesejo wants to merge 2 commits intoapache:mainfrom
Open
refactor(context): deduplicate register/read option-building logic#1479mesejo wants to merge 2 commits intoapache:mainfrom
mesejo wants to merge 2 commits intoapache:mainfrom
Conversation
fe84781 to
39e190f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors PySessionContext read/register APIs to reduce duplicated option-building logic across Parquet/CSV/JSON/Avro operations.
Changes:
- Extracted shared helper functions to convert partition columns / sort order and to build Parquet/JSON/Avro/Csv read options.
- Simplified read/register implementations by removing intermediate variables and consolidating async wait patterns.
- Standardized some path parameters from
PathBufto&strfor JSON/Avro APIs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
timsaucer
reviewed
Apr 8, 2026
Member
timsaucer
left a comment
There was a problem hiding this comment.
Would you mind merging main and giving register_arrow and read_arrow the similar treatment?
Member
|
Nice cleanup! |
Extract shared helpers (convert_partition_cols, convert_file_sort_order, build_parquet/json/avro_options, convert_csv_options), standardize path types to &str, and remove redundant intermediate variables.
74c6fe7 to
9eddc10
Compare
… methods Change path parameters from &str to PathBuf in all register/read methods (register_listing_table, register_parquet, register_json, register_avro, register_arrow, read_json, read_parquet, read_avro, read_arrow) so callers can pass either a Python str or a pathlib.Path object. For register_csv and read_csv, which take &Bound<PyAny> to handle lists, extract path elements as PathBuf rather than String for the same reason. Add a path_to_str helper that converts PathBuf to &str, returning an explicit error for non-UTF-8 paths rather than silently corrupting them. Add build_arrow_options helper to deduplicate register_arrow/read_arrow option-building logic, consistent with the existing parquet/json/avro helpers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
9eddc10 to
f536873
Compare
Contributor
Author
Done |
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.
Which issue does this PR close?
N/A
Rationale for this change
Reduce the number of execution paths for register and read functions
What changes are included in this PR?
Extract shared helpers (convert_partition_cols, convert_file_sort_order, build_parquet/json/avro_options, convert_csv_options), standardize path types to &str, and remove redundant intermediate variables.
Are there any user-facing changes?
No
LLM-generated code disclosure
This PR includes code generated with assistance from an LLM. All LLM-generated content has been manually reviewed and tested.