Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

More verbose output in 'SHOW distributions' command #514

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/clientinteractor/interactor.go
Original file line number Diff line number Diff line change
@@ -531,10 +531,11 @@ func (pi *PSQLInteractor) ShardingRules(ctx context.Context, rules []*shrule.Sha
}

// TODO : unit tests
func (pi *PSQLInteractor) Distributions(ctx context.Context, distributions []*distributions.Distribution) error {
func (pi *PSQLInteractor) Distributions(_ context.Context, distributions []*distributions.Distribution) error {
for _, msg := range []pgproto3.BackendMessage{
&pgproto3.RowDescription{Fields: []pgproto3.FieldDescription{
TextOidFD("Distribution ID"),
TextOidFD("Column types"),
}},
} {
if err := pi.cl.Send(msg); err != nil {
@@ -546,6 +547,7 @@ func (pi *PSQLInteractor) Distributions(ctx context.Context, distributions []*di
if err := pi.cl.Send(&pgproto3.DataRow{
Values: [][]byte{
[]byte(distribution.Id),
[]byte(strings.Join(distribution.ColTypes, ",")),
},
}); err != nil {
spqrlog.Zero.Error().Err(err).Msg("")
4 changes: 1 addition & 3 deletions pkg/coord/local/clocal.go
Original file line number Diff line number Diff line change
@@ -47,9 +47,7 @@ func (lc *LocalCoordinator) ListDistributions(ctx context.Context) ([]*distribut
var retDsp []*distributions.Distribution

for _, dsp := range resp {
retDsp = append(retDsp, &distributions.Distribution{
Id: dsp.ID,
})
retDsp = append(retDsp, distributions.DistributionFromDB(dsp))
}
return retDsp, nil
}
6 changes: 4 additions & 2 deletions test/feature/features/memqdb.feature
Original file line number Diff line number Diff line change
@@ -29,10 +29,12 @@ Feature: MemQDB save state into a file
"""
[
{
"Distribution ID": "ds1"
"Distribution ID": "ds1",
"Column types": "integer"
},
{
"Distribution ID": "ds2"
"Distribution ID": "ds2",
"Column types": "varchar"
}
]
"""
10 changes: 5 additions & 5 deletions test/regress/tests/console/expected/delete_distribution.out
Original file line number Diff line number Diff line change
@@ -49,9 +49,9 @@ DROP DISTRIBUTION ds1 CASCADE;
(1 row)

SHOW distributions;
Distribution ID
-----------------
ds2
Distribution ID | Column types
-----------------+--------------
ds2 |
(1 row)

DROP DISTRIBUTION ALL CASCADE;
@@ -61,8 +61,8 @@ DROP DISTRIBUTION ALL CASCADE;
(1 row)

SHOW distributions;
Distribution ID
-----------------
Distribution ID | Column types
-----------------+--------------
(0 rows)

SHOW key_ranges;
6 changes: 3 additions & 3 deletions test/regress/tests/console/expected/hash.out
Original file line number Diff line number Diff line change
@@ -36,9 +36,9 @@ ALTER DISTRIBUTION ds1 ATTACH RELATION r4 DISTRIBUTION KEY col1 HASH FUNCTION CI
(1 row)

SHOW DISTRIBUTIONS;
Distribution ID
-----------------
ds1
Distribution ID | Column types
-----------------+--------------
ds1 | integer
(1 row)

DROP DISTRIBUTION ALL CASCADE;
12 changes: 6 additions & 6 deletions test/regress/tests/console/expected/show_distributions.out
Original file line number Diff line number Diff line change
@@ -5,23 +5,23 @@
You can find documentation here
https://github.com/pg-sharding/spqr/tree/master/docs

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

CREATE DISTRIBUTION ds2;
CREATE DISTRIBUTION ds2 COLUMN TYPES varchar, integer;
add distribution
----------------------------------
created distribution with id ds2
(1 row)

SHOW distributions;
Distribution ID
-----------------
ds1
ds2
Distribution ID | Column types
-----------------+-----------------
ds1 | integer
ds2 | varchar,integer
(2 rows)

DROP DISTRIBUTION ALL CASCADE;
4 changes: 2 additions & 2 deletions test/regress/tests/console/sql/show_distributions.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE DISTRIBUTION ds1;
CREATE DISTRIBUTION ds2;
CREATE DISTRIBUTION ds1 COLUMN TYPES integer;
CREATE DISTRIBUTION ds2 COLUMN TYPES varchar, integer;

SHOW distributions;

Loading