-
Notifications
You must be signed in to change notification settings - Fork 133
feat: add temporary view option for into_view #1267
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
Conversation
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.
Pull Request Overview
This PR adds support for creating temporary views in addition to regular views through the DataFrame's into_view() method. The key enhancement is adding an optional temporary parameter to control whether the created view should be temporary or permanent.
Key changes:
- Extended the
into_view()method to accept an optionaltemporaryparameter - Implemented
TempViewTablestruct to handle temporary view functionality - Updated tests to validate both temporary and permanent view creation
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/table.rs | Adds TempViewTable struct and TableProvider implementation for temporary views |
| src/dataframe.rs | Updates into_view() method to support temporary parameter and conditional table provider creation |
| python/datafusion/dataframe.py | Adds optional temporary parameter to Python into_view() method |
| python/tests/test_context.py | Parameterizes existing test to verify both temporary and permanent view functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| use crate::dataframe::PyDataFrame; | ||
| use crate::dataset::Dataset; | ||
| use crate::utils::table_provider_from_pycapsule; | ||
| use arrow::datatypes::SchemaRef; | ||
| use arrow::pyarrow::ToPyArrow; | ||
| use async_trait::async_trait; | ||
| use datafusion::catalog::Session; | ||
| use datafusion::common::Column; | ||
| use datafusion::datasource::{TableProvider, TableType}; | ||
| use datafusion::logical_expr::{Expr, LogicalPlanBuilder, TableProviderFilterPushDown}; | ||
| use datafusion::physical_plan::ExecutionPlan; | ||
| use datafusion::prelude::DataFrame; | ||
| use pyo3::prelude::*; | ||
| use std::any::Any; | ||
| use std::sync::Arc; |
Copilot
AI
Oct 13, 2025
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.
[nitpick] The import statements have been reorganized but are not in alphabetical order. Consider grouping imports by crate (std, external crates, internal crates) and sorting alphabetically within each group for better maintainability.
| } | ||
|
|
||
| /// This is nearly identical to `DataFrameTableProvider` | ||
| /// except that it is for temporary tables. |
Copilot
AI
Oct 13, 2025
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.
The comment mentions 'temporary tables' but the struct is for temporary views. Consider updating the comment to say 'temporary views' for accuracy.
| /// except that it is for temporary tables. | |
| /// except that it is for temporary views. |
milenkovicm
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.
@timsaucer not sure if you're looking for a reviewer but it looks good to me
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> - Closes #18026 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> This makes it possible to support temporary views in datafusion-python without code duplication. Ref: apache/datafusion-python#1267 ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - Add new public function `DataFrame::into_temporary_view` - Update `DataFrameTableProvider` with a new member that determines the `table_type` - Add a test ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes, see added test `register_temporary_table` ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> Yes, there is a new public function `DataFrame::into_temporary_view` --------- Co-authored-by: Andrew Lamb <[email protected]>
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#18026 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> This makes it possible to support temporary views in datafusion-python without code duplication. Ref: apache/datafusion-python#1267 ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - Add new public function `DataFrame::into_temporary_view` - Update `DataFrameTableProvider` with a new member that determines the `table_type` - Add a test ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes, see added test `register_temporary_table` ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> Yes, there is a new public function `DataFrame::into_temporary_view` --------- Co-authored-by: Andrew Lamb <[email protected]>
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#18026 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> This makes it possible to support temporary views in datafusion-python without code duplication. Ref: apache/datafusion-python#1267 ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> - Add new public function `DataFrame::into_temporary_view` - Update `DataFrameTableProvider` with a new member that determines the `table_type` - Add a test ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Yes, see added test `register_temporary_table` ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> Yes, there is a new public function `DataFrame::into_temporary_view` --------- Co-authored-by: Andrew Lamb <[email protected]>
Which issue does this PR close?
None
Rationale for this change
This feature allows for creating temporary views. It is needed for the follow on work in #513
What changes are included in this PR?
.into_view()on the DataFrame to set if the view should be temporaryTempViewTableto create a temporary view. This is a copy ofDataFrameTableProviderfrom the upstream repo until Enhance DataFrame table provider to support temporary views datafusion#18026 is resolvedAre there any user-facing changes?
No. Existing code will continue to work as is. This only added an optional parameter to the user facing API.