Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

sql: make SPLIT AT output be consistent with SHOW_RANGES #55543

Merged
merged 1 commit into from
Oct 20, 2020

Conversation

neeral
Copy link
Contributor

@neeral neeral commented Oct 14, 2020

This fixes #24740

The output of the SPLIT AT command returns keys in the form
/Table/52/1/1 whereas the output of SHOW RANGES omits the
prefix, of table id and index id, and displays keys as /1.
This is a little confusing and making them consistent would
make it easier to visually compare.

This patch strips the prefix from the keys in the output of
SPLIT AT.

Release note (sql change): pretty column of SPLIT AT output was changed
by stripping prefix. This makes it consistent with output from SHOW
RANGES.

@blathers-crl
Copy link

blathers-crl bot commented Oct 14, 2020

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

I was unable to automatically find a reviewer. You can try CCing one of the following members:

  • A person you worked with closely on this PR.
  • The person who created the ticket, or a CRDB organization member involved with the ticket (author, commenter, etc.).
  • Join our community slack channel and ask on #contributors.
  • Try find someone else from here.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner labels Oct 14, 2020
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor Author

@neeral neeral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#24740

Manual testing:
Before:

root@:26257/defaultdb> alter table t split at values (2);
      key      |    pretty     |       split_enforced_until
---------------+---------------+-----------------------------------
  \274\211\212 | /Table/52/1/2 | 2262-04-11 23:47:16.854776+00:00
(1 row)

After:

root@:26257/defaultdb> alter table t split at values (2);
      key      | pretty |       split_enforced_until
---------------+--------+-----------------------------------
  \274\211\212 | /2     | 2262-04-11 23:47:16.854776+00:00
(1 row)

cc: @RaduBerinde could you please review or suggest someone to review this

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@neeral
Copy link
Contributor Author

neeral commented Oct 14, 2020

cc: @RaduBerinde @ajwerner for review (or suggest someone to review)

@otan otan requested a review from ajwerner October 14, 2020 15:26
Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to add a logictest, probably in pkg/sql/logictest/testdata/alter_table. Add a test and :lgtm:

On the whole I'm good with this once it gets a test. I wonder if ultimately it'd be better if we had the appropriate tuple of values but I suppose that's neither here nor there and cockroach's ability to deal with tuple types is currently limited.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)

@neeral neeral force-pushed the strip-key-prefix-in-split-table branch from b36f1eb to 5141e11 Compare October 19, 2020 21:09
@blathers-crl
Copy link

blathers-crl bot commented Oct 19, 2020

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@neeral neeral force-pushed the strip-key-prefix-in-split-table branch from 5141e11 to 3f7b1d9 Compare October 19, 2020 21:10
Copy link
Contributor Author

@neeral neeral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for taking a look @ajwerner. I have added a logic test for this.

PTAL

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @neeral)


pkg/sql/logictest/testdata/logic_test/alter_table, line 1421 at r1 (raw file):

Quoted 21 lines of code…
# Test formatting of keys in output of SPLIT AT
query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM TABLE t]
----
start_key  end_key  replicas  lease_holder
NULL       NULL     {1}       1
query TTT colnames
ALTER TABLE t SPLIT AT VALUES (1), (10)
----
key            pretty    split_enforced_until
[213 137 137]  /1        2262-04-11 23:47:16.854776 +0000 +0000
[213 137 146]  /10       2262-04-11 23:47:16.854776 +0000 +0000
query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM TABLE t]
----
start_key  end_key  replicas  lease_holder
NULL       /1       {1}       1
/1         /10      {1}       1
/10        NULL     {1}       1
statement ok
DROP TABLE t

Bad news, we don't support SHOW RANGES in all of our test configs, namely not in 3node-tenant. Can you create a new logictest file (split_at?) for this and put # LogicTest: !3node-tenant at the top. It should look just like

The output of the SPLIT AT command returns keys in the form
`/Table/52/1/1` whereas the output of SHOW RANGES omits the
prefix, of table id and index id, and displays keys as `/1`.
This is a little confusing and making them consistent would
make it easier to visually compare.

This patch strips the prefix from the keys in the output of
SPLIT AT.

Release note (sql change): pretty column of SPLIT AT output was changed
by stripping prefix. This makes it consistent with output from SHOW
RANGES.
@neeral neeral force-pushed the strip-key-prefix-in-split-table branch from 3f7b1d9 to 3ea77b0 Compare October 20, 2020 07:55
Copy link
Contributor Author

@neeral neeral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner)


pkg/sql/logictest/testdata/logic_test/alter_table, line 1421 at r1 (raw file):

Previously, ajwerner wrote…
# Test formatting of keys in output of SPLIT AT
query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM TABLE t]
----
start_key  end_key  replicas  lease_holder
NULL       NULL     {1}       1
query TTT colnames
ALTER TABLE t SPLIT AT VALUES (1), (10)
----
key            pretty    split_enforced_until
[213 137 137]  /1        2262-04-11 23:47:16.854776 +0000 +0000
[213 137 146]  /10       2262-04-11 23:47:16.854776 +0000 +0000
query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder FROM [SHOW RANGES FROM TABLE t]
----
start_key  end_key  replicas  lease_holder
NULL       /1       {1}       1
/1         /10      {1}       1
/10        NULL     {1}       1
statement ok
DROP TABLE t

Bad news, we don't support SHOW RANGES in all of our test configs, namely not in 3node-tenant. Can you create a new logictest file (split_at?) for this and put # LogicTest: !3node-tenant at the top. It should look just like

Ah - strange it didn't fail when I ran make testlogic locally. I've created a new file split_at and reverted changes to alter_table

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm: thanks for the contribution!

bors r=ajwerner

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajwerner)

@craig
Copy link
Contributor

craig bot commented Oct 20, 2020

Build succeeded:

@craig craig bot merged commit 7a576e8 into cockroachdb:master Oct 20, 2020
@neeral neeral deleted the strip-key-prefix-in-split-table branch October 20, 2020 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: make SPLIT AT output be consistent with SHOW EXPERIMENTAL_RANGES
3 participants