-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: disallow DESC option in the last column of inverted indexes #84516
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 16 of 16 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan, @mgartner, and @michae2)
-- commits
line 16 at r1:
I don't think this is true. There are some cases where we scan a range. For example, look at the second span here:
> EXPLAIN (opt) SELECT a FROM json_tab WHERE b @> '{"a": {}}' ORDER BY a
;
info
----------------------------------------------------------------------
sort
└── project
└── inverted-filter
├── inverted expression: /5
│ ├── tight: true, unique: false
│ └── union spans
│ ├── ["7a\x00\x019", "7a\x00\x019"]
│ └── ["7a\x00\x02\x00\xff", "7a\x00\x03")
└── scan json_tab@foo_inv
└── inverted constraint: /5/1
└── spans
├── ["7a\x00\x019", "7a\x00\x019"]
└── ["7a\x00\x02\x00\xff", "7a\x00\x03")
Why can't we just disallow DESC
for now?
Previously, rytaft (Rebecca Taft) wrote…
Good point. I still think it's odd to give the impression that inverted index columns have a semantic ordering. The indexed column contains only one dimension of the value, and an inverted index could never support sort-free ordering on the inverted index column. Postgres disallows ASC on GIN indexes, which is one of the reasons I removed it:
But allowing it would be more backward compatible... @cockroachdb/sql-experience any thoughts? |
assorted thoughts:
|
f312dc9
to
1670877
Compare
I've updated this PR to only disallow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 8 of 8 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @michae2)
1670877
to
19a8d7d
Compare
The last column of inverted indexes cannot have the `DESC` direction. Prior to this commit it was allowed, but caused internal errors. To avoid propagating the notion that inverted indexes have a semantic direction, we stop printing the `ASC` option for inverted index columns in the output of `SHOW CREATE TABLE`. Fixes cockroachdb#84388 Release note (sql change): The last column of an INVERTED INDEX can no longer have the `DESC` option. If `DESC` was used in prior versions, it could cause internal errors.
19a8d7d
to
ad1c8fb
Compare
@@ -1689,5 +1707,5 @@ SELECT primes FROM cb WHERE primes && numbers ORDER BY primes | |||
|
|||
# Regression test for incorrectly unwrapping a DOidWrapper (#84569). | |||
statement ok | |||
CREATE TABLE t84569 (name_col NAME NOT NULL, INVERTED INDEX (name_col gin_trgm_ops DESC)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've confirmed that the bug was reproducible without DESC
, so this regression test remains useful.
TFTR! bors r+ |
Build failed (retrying...): |
Build succeeded: |
The last column of inverted indexes cannot have the
DESC
direction.Prior to this commit it was allowed, but caused internal errors. To
avoid propagating the notion that inverted indexes have a semantic
direction, we stop printing the
ASC
option for inverted index columnsin the output of
SHOW CREATE TABLE
.Fixes #84388
Release note (sql change): The last column of an INVERTED INDEX can no
longer have the
DESC
option. IfDESC
was used in prior versions, itcould cause internal errors.