Repository navigation
Keep a view's file-like source alive through its relation - #689
Draft
evertlammerts wants to merge 1 commit into
Draft
evertlammerts wants to merge 1 commit into
evertlammerts wants to merge 1 commit into
Conversation
evertlammerts
marked this pull request as draft
October 16, 2026 17:04
This branch has not been deployed
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.
Fixes #477. A view created with
to_view()orcreate_view()over a relation that reads a Python file-like object (read_csv(io.StringIO(...)),read_json,read_parqueton a buffer) stopped working once the relation was garbage collected: the next query against the view raised anIOExceptionfor a missing object-store file. The relation owned the registered file object; the view did not, becauseCreateViewRelationcopies the query and the copy drops the relation's external dependency.The view now gets the relation's own query node, with one table reference in it carrying a dependency on the relation. The search for that reference walks the query node, its expressions and subqueries, and picks the first reference whose copy keeps the dependency (base tables, subqueries, table functions, expression lists, column data and SHOW references). A relation that only appears inside a scalar subquery or an
ANYcomparison is found too. The same holds for a replacement scan that resolves to a relation. Column names, including duplicates such asa, a, pass through unchanged.The new test file registers a file-like source, drops every Python reference to it, forces a collection, and reads the view, and it checks the source is released after
DROP VIEW. It covers CTEs that shadow the source name, scalar andANYsubqueries, window expressions, JSON operators, pivots, views over views, and Arrow and pandas sources.One pre-existing problem is pinned with a strict xfail rather than fixed: when the view's query fails during binding, 2.0 raises
SystemErrorinstead of the engine's error. That is a separate regression in the error path.