Skip to content
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

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

Open
knz opened this issue Mar 13, 2019 · 4 comments
Open
Labels
A-sql-execution Relating to SQL execution. A-sql-optimizer SQL logical planning and optimizations. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team X-anchored-telemetry The issue number is anchored by telemetry references.

Comments

@knz
Copy link
Contributor

knz commented Mar 13, 2019

Desired feature:

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

Or, more usefully:

CREATE TABLE t AS SELECT * FROM t AS OF SYSTEM TIME '-1h'

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

@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-optimizer SQL logical planning and optimizations. A-sql-execution Relating to SQL execution. X-anchored-telemetry The issue number is anchored by telemetry references. labels Mar 13, 2019
@jseldess
Copy link
Contributor

@knz, should this be called out as a known limitation?

@knz
Copy link
Contributor Author

knz commented Dec 24, 2020

That sounds right!

Not a new one though, so maybe worth calling out as such in previous versions too.

@awoods187
Copy link
Contributor

This may also be relevant to providing access via bounded staleness in the event of quorum loss.

@ajwerner
Copy link
Contributor

I can imagine CREATE TABLE t AS SELECT * FROM t AS OF SYSTEM TIME '-1h' or perhaps materializing a view as of a system time would be a neat way to work around some issues we've had in the past here. It's a little bit less subtle than generally mixing timestamps within a transaction.

@mgartner mgartner moved this to New Backlog in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-execution Relating to SQL execution. A-sql-optimizer SQL logical planning and optimizations. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team X-anchored-telemetry The issue number is anchored by telemetry references.
Projects
Status: Backlog
Development

No branches or pull requests

5 participants