-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: SHOW PARTITIONS FOR <table> or <index> or <database> #38436
Comments
We should also make sure that SHOW CREATE TABLE shows all partitions on tables and indexes |
So to clarify, we do add partitions to the SHOW CREATE TABLE: CREATE TABLE "orders" (
region STRING NOT NULL,
id UUID DEFAULT gen_random_uuid() NOT NULL,
total DECIMAL NOT NULL,
created_at TIMESTAMP NOT NULL,
PRIMARY KEY (region, id),
UNIQUE INDEX orders_by_created_at (region, created_at, id) STORING (total),
CHECK (region IN ('us-east1', 'us-west1', 'europe-west2'))
)
PARTITION BY LIST (region) (
PARTITION us_east1 VALUES IN ('us-east1'),
PARTITION us_west1 VALUES IN ('us-west1'),
PARTITION europe_west2 VALUES IN ('europe-west2')
); And then:
But, if we add the zone constraints: alter partition us_east1 OF TABLE orders configure zone using constraints='[+region=us-east1]';
CONFIGURE ZONE 1 Those will not show up:
Show create table should show the zone constraints that apply to the table. |
@awoods187 what kind of output are you expecting for the show create table to output here? |
For Movr, first we partition the users table: ALTER TABLE users PARTITION BY LIST (city) ( PARTITION new_york VALUES IN ('new york'), PARTITION chicago VALUES IN ('chicago'), PARTITION seattle VALUES IN ('seattle') ); Then we add constraints: ALTER PARTITION new_york OF TABLE movr.users CONFIGURE ZONE USING constraints='[+region=us-east1]'; ALTER PARTITION chicago OF TABLE movr.users CONFIGURE ZONE USING constraints='[+region=us-central1]'; ALTER PARTITION seattle OF TABLE movr.users CONFIGURE ZONE USING constraints='[+region=us-west1]';`)
Post adding in constraints I'm imagining:
With some in-line comments that show constraints. Note, I also just realized that if you run
|
39053: sql: Add support for a show partitions command. r=rohany a=rohany SHOW PARTITIONS FROM TABLE <table> SHOW PARTITIONS FROM DATABASE <database> SHOW PARTITIONS FROM INDEX <index> Returns a table containing the following columns. * database_name * table_name * partition_name * parent_partition * column_names * index_name * partition_values * zone_constraints (NULL if no constraints were specified) To do this, changes were made to the crdb_internal.partitions table. Addresses #38436 Release note (sql change): Add support for a SHOW PARTITIONS command. Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
Table
It is not documented but users can run:
Database
It is not documented but users can run:
We should make SHOW statements that allow for users to see this information easily.
The text was updated successfully, but these errors were encountered: