cockroachdb / cockroachdb/cockroach

sql/schemachanger: implement CREATE TEMPORARY VIEW in the declarative schema changer

Open
#164,272 0 comments 0 reactions 0 assignees View on GitHub
A-schema-changer-impl C-enhancement T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

## Summary

Add `CREATE TEMPORARY VIEW` support to the declarative schema changer, including auto-promotion to temporary when the view references temporary tables.

## Describe the solution you'd like

- Remove the `NotImplementedErrorf` panic for `n.Persistence.IsTemporary()` in `create_view.go`
- Set `IsTemporary: true` on the View element; create in the `pg_temp` schema
- Auto-promote to temporary if any referenced relation is temporary (send `pgnotice` like the legacy path does)
- Pass `Temporary: true` to the `CreateViewDescriptor` op
- Update `createViewChecks` in `process.go` to allow temporary views
- Add scbuild, scplan, and end-to-end logic tests

## Code References

- [create_view.go:26](https://github.com/cockroachdb/cockroach/blob/7f85419e8fa/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_view.go#L26) — `NotImplementedErrorf` panic for temporary views
- [create_view.go:130-137](https://github.com/cockroachdb/cockroach/blob/7f85419e8fa/pkg/sql/create_view.go#L130-L137) — legacy auto-promotion to temporary logic
- [create_view.go:184](https://github.com/cockroachdb/cockroach/blob/7f85419e8fa/pkg/sql/create_view.go#L184) — legacy temporary view handling

Epic: CRDB-31466

Jira issue: CRDB-60727

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.