Skip to content

sql: support different AS OF SYSTEM TIME timestamps inside a single statement #35712

@knz

Description

@knz

Desired feature:

SELECT * FROM t AS OF SYSTEM TIME '-1h', u AS OF SYSTEM TIME '-2h'

Or, more usefully:

INSERT INTO t1 SELECT * FROM t2 AS OF SYSTEM TIME '-1h'
CREATE TABLE t AS SELECT * FROM t AS OF SYSTEM TIME '-1h'

Update: #142147 has addressed this specifically for CREATE TABLE AS statements.


The idea here is that currently, the same client.Txn object is used for an entire statement, but there is no reason why this should remain true.

Single read-only relational nodes, especially table readers, could use a different Txn object with a historical timestamp.

Epic: CRDB-9838

Jira issue: CRDB-4561

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-executionRelating to SQL execution.A-sql-optimizerSQL logical planning and optimizations.C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)T-sql-queriesSQL Queries TeamX-anchored-telemetryThe issue number is anchored by telemetry references.

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions