Skip to content

Materialize PyDough Queries as Database Views/Tables #499

@hadia206

Description

@hadia206

Problem

PyDough queries currently produce results only at read time (to_df, to_sql). There's no way to persist an intermediate result as a table or view in the database and reuse it in subsequent queries. This is a common pattern for breaking up complex multi-step analytics.

Proposed solution

Add a pydough.to_table() function that executes a query, writes the result to the database, and returns a collection that can be used in follow-up PyDough queries.

Example:

asian_nations = nations.WHERE(region.name == 'ASIA').CALCULATE(key, name)
asian_tmp = pydough.to_table(asian_nations, name='asian_nations', replace=True)

# Use in a subsequent query
result = asian_tmp.CALCULATE(name).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions