cockroachdb / cockroachdb/cockroach
partialidx: ignore implicit casts during implication
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Currently, the partial-index implicator is unable to tell that a filter is equivalent to a partial-index expression in the following example:
```
root@localhost:26257/defaultdb> CREATE TABLE t (k VARCHAR, v INT, INDEX foo (v) WHERE k::STRING = 'PENDING'::STRING);
CREATE TABLE
Time: 4ms total (execution 4ms / network 0ms)
root@localhost:26257/defaultdb> SELECT * FROM t@foo WHERE k = 'PENDING';
ERROR: index "foo" is a partial index that does not contain all the rows needed to execute this query
SQLSTATE: 42809
```
This is because of the `VARCHAR` -> `STRING` cast, even though the cast can be made implicitly. It should be possible for the implicator to prove that the filter and index expression are equivalent.
Jira issue: CRDB-24987
Contributor guide
Assessment
This issue has not been assessed yet.