Skip to content

Commit

Permalink
Fix hints (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
reshke authored Jul 8, 2024
1 parent 7dd9180 commit be3f5b8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
3 changes: 1 addition & 2 deletions test/regress/schedule/router
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ test: with_tables
test: single_shard_joins
test: multishard
test: error
# TODO: fix this
# test: routing_hint
test: routing_hint
test: begin
test: switch_distribution
test: alter_distribution
Expand Down
40 changes: 22 additions & 18 deletions test/regress/tests/router/expected/routing_hint.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,39 @@
https://github.com/pg-sharding/spqr/tree/master/docs

CREATE DISTRIBUTION ds1 COLUMN TYPES integer;
add distribution
----------------------------------
created distribution with id ds1
add distribution
------------------------
distribution id -> ds1
(1 row)

CREATE KEY RANGE krid1 FROM 1 ROUTE TO sh1 FOR DISTRIBUTION ds1;
add key range
--------------------------------
created key range with bound 1
add key range
---------------
bound -> 1
(1 row)

CREATE KEY RANGE krid2 FROM 11 ROUTE TO sh2 FOR DISTRIBUTION ds1;
add key range
---------------------------------
created key range with bound 11
add key range
---------------
bound -> 11
(1 row)

ALTER DISTRIBUTION ds1 ATTACH RELATION test DISTRIBUTION KEY id;
attach table
--------------------------------------------
attached relation test to distribution ds1
(1 row)
attach table
-------------------------
relation name -> test
distribution id -> ds1
(2 rows)

\c regress
CREATE TABLE test(id int, age int);
NOTICE: send query to shard(s) : sh1,sh2
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 30*/;
-- TODO: specify distribution as well as sharding_key
INSERT INTO test(id, age) VALUES (1210, 16) /*__spqr__sharding_key: 1, __spqr__distribution: ds1 */;
NOTICE: send query to shard(s) : sh1
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 30, __spqr__distribution: ds1 */;
NOTICE: send query to shard(s) : sh2
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 3000*/;
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 3000, __spqr__distribution: ds1 */;
NOTICE: send query to shard(s) : sh2
DROP TABLE test;
NOTICE: send query to shard(s) : sh1,sh2
Expand All @@ -48,9 +52,9 @@ NOTICE: send query to shard(s) : sh1,sh2
https://github.com/pg-sharding/spqr/tree/master/docs

DROP DISTRIBUTION ALL CASCADE;
drop distribution
-----------------------
drop distribution ds1
drop distribution
------------------------
distribution id -> ds1
(1 row)

DROP KEY RANGE ALL;
Expand Down
7 changes: 4 additions & 3 deletions test/regress/tests/router/sql/routing_hint.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ ALTER DISTRIBUTION ds1 ATTACH RELATION test DISTRIBUTION KEY id;

CREATE TABLE test(id int, age int);
-- TODO: specify distribution as well as sharding_key
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 30*/;
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 3000*/;
INSERT INTO test(id, age) VALUES (1210, 16) /*__spqr__sharding_key: 1, __spqr__distribution: ds1 */;
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 30, __spqr__distribution: ds1 */;
INSERT INTO test(id, age) VALUES (10, 16) /*__spqr__sharding_key: 3000, __spqr__distribution: ds1 */;

DROP TABLE test;

\c spqr-console
DROP DISTRIBUTION ALL CASCADE;
DROP KEY RANGE ALL;
DROP KEY RANGE ALL;

0 comments on commit be3f5b8

Please sign in to comment.