cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

sql: make SPLIT AT output be consistent with SHOW EXPERIMENTAL_RANGES

Open rmloveland opened this issue 8 years ago • 7 comments

This is a feature request.

On version 2.0.0, the pretty-printed key output format differs between SHOW TESTING_RANGES and SPLIT AT as shown below.

This is a bit confusing when you are trying to learn the key output format so you can understand what is happening under the hood when you execute these statements.

The feature request is for SPLIT AT to use the same "short form" as SHOW TESTING_RANGES to make it easier to visually compare the outputs.

(The table t below is taken from the SQL tests for the SHOW TESTING_RANGES PR.)


    > SELECT version();
    +-----------------------------------------------------------------------------------+
    |                                      version                                      |
    +-----------------------------------------------------------------------------------+
    | CockroachDB CCL v2.0.0 (x86_64-apple-darwin13, built 2018/04/03 20:52:33, go1.10) |
    +-----------------------------------------------------------------------------------+
    (1 row)

    > SHOW CREATE TABLE t;
    +-------+------------------------------------------------------------+
    | Table |                        CreateTable                         |
    +-------+------------------------------------------------------------+
    | t     | CREATE TABLE t (                                          +|
    |       |         k1 INT NOT NULL,                                  +|
    |       |         k2 INT NOT NULL,                                  +|
    |       |         v INT NULL,                                       +|
    |       |         w INT NULL,                                       +|
    |       |         CONSTRAINT "primary" PRIMARY KEY (k1 ASC, k2 ASC),+|
    |       |         INDEX idx (v ASC, w ASC),                         +|
    |       |         FAMILY "primary" (k1, k2, v, w)                   +|
    |       | )                                                          |
    +-------+------------------------------------------------------------+
    (1 row)

    > ALTER TABLE t SPLIT AT VALUES (1), (10);
    +----------+----------------+
    |   key    |     pretty     |
    +----------+----------------+
    | \xbc8989 | /Table/52/1/1  |
    | \xbc8992 | /Table/52/1/10 |
    +----------+----------------+
    (2 rows)

    root=> SHOW TESTING_RANGES FROM TABLE t;
    +-----------+---------+----------+----------+--------------+
    | Start Key | End Key | Range ID | Replicas | Lease Holder |
    +-----------+---------+----------+----------+--------------+
    |           | /1      |       33 | {1,3,4}  |            3 |
    | /1        | /10     |       34 | {1,3,5}  |            3 |
    | /10       |         |       35 | {1,3,5}  |            3 |
    +-----------+---------+----------+----------+--------------+
    (3 rows)

rmloveland avatar Apr 12 '18 19:04 rmloveland

cc @RaduBerinde and @knz

rmloveland avatar Apr 12 '18 19:04 rmloveland

I don't see a problem with removing the /Table/<id>/<idx> prefix. In addition, I am not sure if the key column is useful at all. If it is used internally, we could hide it by default.

RaduBerinde avatar Apr 12 '18 19:04 RaduBerinde

Greetings!

I am new here and I am very interested to start contributing by picking up a good first issue like this. I was wondering if it is ok to start working on this and any clue you can give me to start hacking with.

Thanks :smiley:

rasouli avatar Jun 22 '20 16:06 rasouli

Hi @rasouli, go ahead! I'd first look at how SHOW RANGES is implemented (pkg/sql/delegate/show_ranges.go), and then the code that drives ALTER TABLE SPLIT AT in pkg/sql/split.go.

rohany avatar Jun 25 '20 14:06 rohany

In order to make this change you'll need to change the set of columns returned from the Values() method on the splitNode in split.go. You'll also need to update the result columns from that node. The set of columns returned from the split node is:

https://github.com/cockroachdb/cockroach/blob/bf975d413f814d612f01212a38b61765a99efb6e/pkg/sql/sqlbase/result_columns.go#L209

ajwerner avatar Jun 26 '20 01:06 ajwerner

@rasouli are you working on this? If not, I'd like to pick it up.

neeral avatar Oct 14 '20 05:10 neeral

@rasouli are you working on this? If not, I'd like to pick it up.

Hi neeral, please go ahead, unfortunately I have been very busy since then. best of luck.

rasouli avatar Oct 14 '20 05:10 rasouli