Skip to content

sql: support CREATE TABLE AS ... WITH NO DATA#171440

Merged
rail merged 1 commit into
cockroachdb:masterfrom
virajchogle:ctas-with-no-data-171333
Jun 6, 2026
Merged

sql: support CREATE TABLE AS ... WITH NO DATA#171440
rail merged 1 commit into
cockroachdb:masterfrom
virajchogle:ctas-with-no-data-171333

Conversation

@virajchogle

Copy link
Copy Markdown
Contributor

Fixes #171333

Adds support for CREATE TABLE AS ... WITH NO DATA, matching PostgreSQL.

Coverage in pkg/sql/logictest/testdata/logic_test/create_as includes regular tables, explicit WITH DATA, default behavior, IF NOT EXISTS, and TEMP TABLE.

Epic: none

Release note (sql change): CREATE TABLE AS ... WITH NO DATA is now supported. It creates the destination table with the source query's schema and no rows, matching PostgreSQL

@virajchogle virajchogle requested review from a team as code owners June 4, 2026 15:23
@virajchogle virajchogle requested review from michae2 and spilchen and removed request for a team June 4, 2026 15:23
@trunk-io

trunk-io Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@blathers-crl

blathers-crl Bot commented Jun 4, 2026

Copy link
Copy Markdown

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl Bot added the O-community Originated from the community label Jun 4, 2026
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@rafiss rafiss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your contribution. you need to run ./dev gen docs and then this can get merged

Match PostgreSQL by creating the destination table with the SELECT's schema and no rows when WITH NO DATA is specified.

Fixes cockroachdb#171333

Epic: none

Release note (sql change): CREATE TABLE AS ... WITH NO DATA is now supported. It creates the destination table with the source query's schema and no rows, matching PostgreSQL.
@virajchogle virajchogle force-pushed the ctas-with-no-data-171333 branch from 86f510d to 9f0d237 Compare June 5, 2026 16:14
@blathers-crl

blathers-crl Bot commented Jun 5, 2026

Copy link
Copy Markdown

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@rafiss rafiss requested a review from rail June 6, 2026 14:33
@rail rail merged commit 5f5932a into cockroachdb:master Jun 6, 2026
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community target-release-26.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CREATE TABLE AS ... WITH NO DATA

4 participants