Skip to content

Commit

Permalink
schemachanger: prettier EXPLAIN (DDL) output
Browse files Browse the repository at this point in the history
This commit adds ID -> name mappings to the scpb.TargetState
which lies at the heart of the declarative schema changer,
these mappings are then used (when present) to decorate the
output of EXPLAIN (DDL) in an effort to make it more understandable.

This commit also adds support for the SHAPE flag in conjunction with
EXPLAIN (DDL). The generated output informs on expensive operations
such as backfills or validations.

Fixes #104043.

Release note (sql change): EXPLAIN (DDL) statements now have
descriptor, index, column, constraint and other ID values
decorated with names when available. There is now also a new
EXPLAIN (DDL, SHAPE) statement which provides information on
costly operations planned by the declarative schema changer,
like which index backfills and validations will get performed.
  • Loading branch information
postamar committed May 29, 2023
1 parent f397cf9 commit d6b4b64
Show file tree
Hide file tree
Showing 574 changed files with 21,675 additions and 19,209 deletions.
28 changes: 28 additions & 0 deletions pkg/ccl/schemachangerccl/testdata/end_to_end/create_index
Expand Up @@ -157,6 +157,20 @@ upsert descriptor #104
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ columns:
+ "1": id
+ "2": name
+ "3": money
+ "4294967294": tableoid
+ "4294967295": crdb_internal_mvcc_timestamp
+ families:
+ "0": primary
+ id: 104
+ indexes:
+ "1": t1_pkey
+ "2": id1
+ name: t1
+ relevantStatements:
+ - statement:
+ redactedStatement: CREATE INDEX ‹id1› ON ‹defaultdb›.‹public›.‹t1› (‹id›,
Expand Down Expand Up @@ -457,6 +471,20 @@ upsert descriptor #104
- userName: root
- currentStatuses: <redacted>
- jobId: "1"
- nameMapping:
- columns:
- "1": id
- "2": name
- "3": money
- "4294967294": tableoid
- "4294967295": crdb_internal_mvcc_timestamp
- families:
- "0": primary
- id: 104
- indexes:
- "1": t1_pkey
- "2": id1
- name: t1
- relevantStatements:
- - statement:
- redactedStatement: CREATE INDEX ‹id1› ON ‹defaultdb›.‹public›.‹t1› (‹id›,
Expand Down
Expand Up @@ -99,6 +99,9 @@ upsert descriptor #104
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 104
+ name: multi_region_test_db
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP DATABASE ‹multi_region_test_db› CASCADE
Expand All @@ -124,6 +127,9 @@ upsert descriptor #105
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 105
+ name: public
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP DATABASE ‹multi_region_test_db› CASCADE
Expand All @@ -147,6 +153,9 @@ upsert descriptor #106
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 106
+ name: crdb_internal_region
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP DATABASE ‹multi_region_test_db› CASCADE
Expand All @@ -171,6 +180,9 @@ upsert descriptor #107
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 107
+ name: _crdb_internal_region
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP DATABASE ‹multi_region_test_db› CASCADE
Expand All @@ -195,6 +207,9 @@ upsert descriptor #108
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 108
+ name: table_regional_by_table
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP DATABASE ‹multi_region_test_db› CASCADE
Expand Down Expand Up @@ -233,6 +248,9 @@ upsert descriptor #108
- userName: root
- currentStatuses: <redacted>
- jobId: "1"
- nameMapping:
- id: 108
- name: table_regional_by_table
- relevantStatements:
- - statement:
- redactedStatement: DROP DATABASE ‹multi_region_test_db› CASCADE
Expand Down
Expand Up @@ -74,6 +74,7 @@ upsert descriptor #106
+ authorization:
+ userName: root
+ jobId: "1"
+ nameMapping: {}
enumMembers:
- logicalRepresentation: us-east1
...
Expand All @@ -94,6 +95,7 @@ upsert descriptor #107
+ authorization:
+ userName: root
+ jobId: "1"
+ nameMapping: {}
id: 107
kind: ALIAS
...
Expand All @@ -112,6 +114,9 @@ upsert descriptor #108
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 108
+ name: table_regional_by_row
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP TABLE ‹multi_region_test_db›.‹public›.‹table_regional_by_row›
Expand Down Expand Up @@ -147,6 +152,7 @@ upsert descriptor #106
- authorization:
- userName: root
- jobId: "1"
- nameMapping: {}
enumMembers:
- logicalRepresentation: us-east1
...
Expand All @@ -162,6 +168,7 @@ upsert descriptor #107
- authorization:
- userName: root
- jobId: "1"
- nameMapping: {}
id: 107
kind: ALIAS
...
Expand All @@ -178,6 +185,9 @@ upsert descriptor #108
- userName: root
- currentStatuses: <redacted>
- jobId: "1"
- nameMapping:
- id: 108
- name: table_regional_by_row
- relevantStatements:
- - statement:
- redactedStatement: DROP TABLE ‹multi_region_test_db›.‹public›.‹table_regional_by_row›
Expand Down
Expand Up @@ -67,6 +67,7 @@ upsert descriptor #106
+ authorization:
+ userName: root
+ jobId: "1"
+ nameMapping: {}
enumMembers:
- logicalRepresentation: us-east1
...
Expand All @@ -88,6 +89,9 @@ upsert descriptor #108
+ userName: root
+ currentStatuses: <redacted>
+ jobId: "1"
+ nameMapping:
+ id: 108
+ name: table_regional_by_table
+ relevantStatements:
+ - statement:
+ redactedStatement: DROP TABLE ‹multi_region_test_db›.‹public›.‹table_regional_by_table›
Expand Down Expand Up @@ -125,6 +129,7 @@ upsert descriptor #106
- authorization:
- userName: root
- jobId: "1"
- nameMapping: {}
enumMembers:
- logicalRepresentation: us-east1
...
Expand All @@ -141,6 +146,9 @@ upsert descriptor #108
- userName: root
- currentStatuses: <redacted>
- jobId: "1"
- nameMapping:
- id: 108
- name: table_regional_by_table
- relevantStatements:
- - statement:
- redactedStatement: DROP TABLE ‹multi_region_test_db›.‹public›.‹table_regional_by_table›
Expand Down

0 comments on commit d6b4b64

Please sign in to comment.