-
Notifications
You must be signed in to change notification settings - Fork 24
feat!(pkg-r): new data_source plugin API
#123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
14ee321 to
f40c505
Compare
f40c505 to
8350cbe
Compare
gadenbuie
reviewed
Dec 3, 2025
gadenbuie
reviewed
Dec 3, 2025
gadenbuie
reviewed
Dec 3, 2025
gadenbuie
reviewed
Dec 3, 2025
gadenbuie
reviewed
Dec 3, 2025
gadenbuie
reviewed
Dec 3, 2025
gadenbuie
reviewed
Dec 3, 2025
Co-authored-by: Garrick Aden-Buie <[email protected]>
gadenbuie
approved these changes
Dec 3, 2025
Contributor
gadenbuie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really like this approach, it's nice, clean and easy to follow!
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.
Migrate R Data Source API to R6 Classes
Overview
This PR migrates the R package's data source API from an S3-based approach to an R6 class-based approach, aligning it with the Python package's design. This is a (developer facing) breaking change that provides a cleaner, more maintainable API.
Changes
New R6 Class Hierarchy
Base Class:
DataSourceget_db_type()- Returns database type stringget_schema(categorical_threshold = 20)- Returns schema informationexecute_query(query)- Executes SQL and returns data frametest_query(query)- Tests query by fetching one rowget_data()- Returns all unfiltered datacleanup()- Cleans up resourcestable_name- Name of the tableConcrete Classes:
DataFrameSource- Wraps data frames using DuckDBDBISource- Wraps DBI database connectionsBreaking Changes
Old API (Removed)
New API
Internal Changes
data_source.R- Complete rewrite with R6 classesDataSource,DataFrameSource,DBISourceclassesget_schema_impl(),r_class_to_sql_type()create_system_prompt()toget_system_prompt()(internal)QueryChat.Rnormalize_data_source()to auto-convert to R6 classescleanup()to calldata_source$cleanup()method$data_sourceis now an active binding (field), not a methodquerychat_tools.R$method syntaxget_db_type(source)tosource$get_db_type()execute_query(source, query)tosource$execute_query(query)Benefits
privatelistDataSourcefor custom implementations instead of defining a handful of (poorly defined) S3 methods.Example: Extending DataSource
Users can now easily create custom data sources: