sql: make SPLIT AT output be consistent with SHOW EXPERIMENTAL_RANGES
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)
cc @RaduBerinde and @knz
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.
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:
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.
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
@rasouli are you working on this? If not, I'd like to pick it up.
@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.