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: fix CREATE TABLE AS sourcing SHOW <show_subcmd> <table> job failures #107099

Merged
merged 1 commit into from
Jul 19, 2023
Merged

sql: fix CREATE TABLE AS sourcing SHOW <show_subcmd> <table> job failures #107099

merged 1 commit into from
Jul 19, 2023

Conversation

ecwall
Copy link
Contributor

@ecwall ecwall commented Jul 18, 2023

Fixes #106260

Previously CREATE TABLE AS/CREATE MATERIALIZED VIEW AS sourcing from SHOW <show_subcmd> <table> generated a failing schema change job with a relation "tbl" does not exist error because the SHOW source table was not fully qualified.

This PR fixes this by respecting the Builder.qualifyDataSourceNamesInAST flag in delegate.TryDelegate() which implements the failing SHOW commands.

Release note (bug fix): Fix failing schema change job when CREATE TABLE AS or CREATE MATERAILIZED VIEW AS sources from a SHOW command:

  1. CREATE TABLE t AS SELECT * FROM [SHOW CREATE TABLE tbl];
  2. CREATE TABLE t AS SELECT * FROM [SHOW INDEXES FROM tbl];
  3. CREATE TABLE t AS SELECT * FROM [SHOW COLUMNS FROM tbl];
  4. CREATE TABLE t AS SELECT * FROM [SHOW CONSTRAINTS FROM tbl];
  5. CREATE TABLE t AS SELECT * FROM [SHOW PARTITIONS FROM TABLE tbl];
  6. CREATE TABLE t AS SELECT * FROM [SHOW PARTITIONS FROM INDEX tbl@tbl_pkey];

@ecwall ecwall requested review from a team as code owners July 18, 2023 18:41
@ecwall ecwall requested a review from yuzefovich July 18, 2023 18:41
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ecwall ecwall requested review from chengxiong-ruan and rafiss July 18, 2023 18:43
…failures

Fixes #106260

Previously `CREATE TABLE AS`/`CREATE MATERIALIZED VIEW AS` sourcing from
`SHOW <show_subcmd> <table>` generated a failing schema change job with a
`relation "tbl" does not exist error` because the SHOW source table was not
fully qualified.

This PR fixes this by respecting the `Builder.qualifyDataSourceNamesInAST` flag
in `delegate.TryDelegate()` which implements the failing SHOW commands.

Release note (bug fix): Fix failing schema change job when CREATE TABLE AS or
CREATE MATERAILIZED VIEW AS sources from a SHOW command:
1. CREATE TABLE t AS SELECT * FROM [SHOW CREATE TABLE tbl];
2. CREATE TABLE t AS SELECT * FROM [SHOW INDEXES FROM tbl];
3. CREATE TABLE t AS SELECT * FROM [SHOW COLUMNS FROM tbl];
4. CREATE TABLE t AS SELECT * FROM [SHOW CONSTRAINTS FROM tbl];
5. CREATE TABLE t AS SELECT * FROM [SHOW PARTITIONS FROM TABLE tbl];
6. CREATE TABLE t AS SELECT * FROM [SHOW PARTITIONS FROM INDEX tbl@tbl_pkey];
@yuzefovich yuzefovich removed their request for review July 18, 2023 19:06
@ecwall ecwall added backport-22.2.x backport-23.1.x Flags PRs that need to be backported to 23.1 labels Jul 19, 2023
Copy link
Contributor

@chengxiong-ruan chengxiong-ruan left a comment

Choose a reason for hiding this comment

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

LGTM.

@ecwall
Copy link
Contributor Author

ecwall commented Jul 19, 2023

bors r=chengxiong-ruan

@craig craig bot merged commit e23993f into cockroachdb:master Jul 19, 2023
@craig
Copy link
Contributor

craig bot commented Jul 19, 2023

Build succeeded:

@blathers-crl
Copy link

blathers-crl bot commented Jul 19, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error setting reviewers, but backport branch blathers/backport-release-22.2-107099 is ready: POST https://api.github.com/repos/cockroachdb/cockroach/pulls/107219/requested_reviewers: 422 Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the cockroachdb/cockroach repository. []

Backport to branch 22.2.x failed. See errors above.


error setting reviewers, but backport branch blathers/backport-release-23.1-107099 is ready: POST https://api.github.com/repos/cockroachdb/cockroach/pulls/107220/requested_reviewers: 422 Reviews may only be requested from collaborators. One or more of the teams you specified is not a collaborator of the cockroachdb/cockroach repository. []

Backport to branch 23.1.x failed. See errors above.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: CREATE AS [SHOW <show_subcmd> <table>] job fails
3 participants