Skip to content

Commit

Permalink
sql: Implement ALTER TABLE ... LOCALITY REGIONAL BY TABLE from GLOBAL
Browse files Browse the repository at this point in the history
Implements ALTER TABLE ... LOCALITY REGIONAL BY TABLE (all permutations)
from LOCALITY GLOBAL.

Release note (sql change): Implements ALTER TABLE ... LOCALITY REGIONAL
BY TABLE from LOCALITY GLOBAL.
  • Loading branch information
ajstorm committed Jan 25, 2021
1 parent 2ec7d92 commit 31fb880
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 125 deletions.
79 changes: 74 additions & 5 deletions pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ statement error unimplemented: implementation pending
ALTER TABLE regional_by_row SET LOCALITY REGIONAL BY TABLE

statement error unimplemented: implementation pending
ALTER TABLE regional_by_row SET LOCALITY REGIONAL BY TABLE in "ap-southeast"
ALTER TABLE regional_by_row SET LOCALITY REGIONAL BY TABLE in "ap-southeast-2"

statement error unimplemented: implementation pending
ALTER TABLE regional_by_row SET LOCALITY REGIONAL BY TABLE in PRIMARY REGION
Expand Down Expand Up @@ -192,15 +192,84 @@ DATABASE alter_locality_test ALTER DATABASE alter_locality_test CONFIGURE ZONE
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'

statement error unimplemented: implementation pending
statement ok
ALTER TABLE global SET LOCALITY REGIONAL BY TABLE

statement error unimplemented: implementation pending
ALTER TABLE global SET LOCALITY REGIONAL BY TABLE in "ap-southeast"
query TT
SHOW CREATE TABLE global
----
global CREATE TABLE public.global (
i INT8 NULL,
FAMILY "primary" (i, rowid)
) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION

statement error unimplemented: implementation pending
query TT
SHOW ZONE CONFIGURATION FOR TABLE global
----
DATABASE alter_locality_test ALTER DATABASE alter_locality_test CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'

# Alter back, to get back to original state
statement ok
ALTER TABLE global SET LOCALITY GLOBAL

statement ok
ALTER TABLE global SET LOCALITY REGIONAL BY TABLE in "ap-southeast-2"

query TT
SHOW CREATE TABLE global
----
global CREATE TABLE public.global (
i INT8 NULL,
FAMILY "primary" (i, rowid)
) LOCALITY REGIONAL BY TABLE IN "ap-southeast-2"

query TT
SHOW ZONE CONFIGURATION FOR TABLE global
----
TABLE global ALTER TABLE global CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 3}',
lease_preferences = '[[+region=ap-southeast-2]]'

# Alter back, to get back to original state
statement ok
ALTER TABLE global SET LOCALITY GLOBAL

statement ok
ALTER TABLE global SET LOCALITY REGIONAL BY TABLE in PRIMARY REGION

query TT
SHOW CREATE TABLE global
----
global CREATE TABLE public.global (
i INT8 NULL,
FAMILY "primary" (i, rowid)
) LOCALITY REGIONAL BY TABLE IN PRIMARY REGION

query TT
SHOW ZONE CONFIGURATION FOR TABLE global
----
DATABASE alter_locality_test ALTER DATABASE alter_locality_test CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'

# Alter back, to get back to original state
statement ok
ALTER TABLE global SET LOCALITY GLOBAL

statement ok
ALTER TABLE global SET LOCALITY GLOBAL

Expand Down
Loading

0 comments on commit 31fb880

Please sign in to comment.