-
Notifications
You must be signed in to change notification settings - Fork 605
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
feat(api): avoid caching physical tables #9976
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1589,6 +1589,24 @@ | |
} | ||
) | ||
|
||
def _should_cache_physical_table(self, op: ops.PhysicalTable) -> bool: | ||
if isinstance(op, (ops.DatabaseTable, ops.UnboundTable)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels like a property we should encode on the operation itself instead of leaving it up to the backend. Is that not possible for some reason? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I covered this in the PR body above. I agree that that would be one potentially nicer option (that's bullet 2 above). |
||
# Cache temp views since they're used for `read_csv`/`read_parquet` | ||
# and may point to remote data, don't cache anything else. | ||
sql = ( | ||
sg.select(sg.func("any_value", C.table_type.eq("VIEW"))) | ||
.from_(sg.table("tables", db="information_schema")) | ||
.where( | ||
C.table_catalog.eq(op.namespace.catalog or self.current_catalog), | ||
C.table_schema.eq(op.namespace.database or self.current_database), | ||
) | ||
.sql(self.dialect) | ||
) | ||
with self._safe_raw_sql(sql) as cur: | ||
result = cur.fetchone() | ||
return True if result is None else result[0] | ||
return False | ||
|
||
def _register_in_memory_table(self, op: ops.InMemoryTable) -> None: | ||
name = op.name | ||
try: | ||
|
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.
Most of this code is unrelated to the backend and is about some property of an expression.
Can we define this as an attribute on
ops.Relation
subclasses? Seems like it'd be much less squishy that way.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.
Meaning the decision is consistent and only based on the operation type (no query in the backend needed)? That's option 2 listed above.