Skip to content

Conversation

@timsaucer
Copy link
Member

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?

Are 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.

@timsaucer timsaucer requested a review from Copilot October 13, 2025 12:08
Copy link
Contributor

Copilot AI left a 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 optional temporary parameter
  • Implemented TempViewTable struct 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.

Comment on lines +18 to 32
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;
Copy link

Copilot AI Oct 13, 2025

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.

Copilot uses AI. Check for mistakes.
}

/// This is nearly identical to `DataFrameTableProvider`
/// except that it is for temporary tables.
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
/// except that it is for temporary tables.
/// except that it is for temporary views.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@milenkovicm milenkovicm left a 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

@timsaucer timsaucer merged commit 030873b into apache:main Oct 15, 2025
16 checks passed
@timsaucer timsaucer deleted the feat/temporary-views branch October 15, 2025 08:57
github-merge-queue bot pushed a commit to apache/datafusion that referenced this pull request Oct 29, 2025
## 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]>
tobixdev pushed a commit to tobixdev/datafusion that referenced this pull request Nov 2, 2025
## 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]>
codetyri0n pushed a commit to codetyri0n/datafusion that referenced this pull request Nov 11, 2025
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants