Skip to content

Caching relations #968

@Barney-x1

Description

@Barney-x1

I couldn't see anything saying this was supported, but I might have missed something.

Selecting interim results to a temp table is extremely useful when creating complex queries, and enables reuse in sets of related queries. It also negates the need for the dreaded nested query.

I appreciate that database writes are deprioritised for PRQL (good decision!) but select into is really a query tool, not a conventional database "write".

Possible syntax would be (as the last line of a query) into new table_name. The "new" would make a distinction between this and "INSERT INTO SELECT" (insert in existing table). Whether to support

  1. non temp tables
  2. insert into existing table (syntax into table_name)

at this stage is debateable. They are not really query-support functions like insertion into a temp table, but it seems perverse not to support them if the extra work is minimal.

If permanent tables are supported (or may be supported in future), there needs to be a way to distinguish this in the into clause, either into new temp table_name or perhaps into new #table_name (that being the convention for temp tables in some SQL dialects).

There is also the question of whether to support global temporary tables... local is by far the more common use case so probably not at present.

NB: "CREATE [TEMPORARY] TABLE ... AS SELECT ..." is the syntax in Oracle, MySQL & maybe others for what is "SELECT INTO" in SqlServer.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions