cockroachdb / cockroachdb/cockroach

sql/jsonpath: add jsonpath index acceleration for rule test

Open
#154,477 0 comments 0 reactions 1 assignee Claimed by @ZhouXing19 View on GitHub
C-enhancement T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

We implemented jsonpath inverted index acceleration in #150793, and we should add test for the span expression . The test should be added under `pkg/sql/opt/xform -f TestRules/select`.

We will also need to fix the print logic for encoding to cover the case for inverted spans for jsonpath expression, specifically for those end with a key. (e.g. '$.a.b'). Currently, the start key is printed as `???`. This is because we don't escape the start key of the span. We should expect the following result:

```
opt expect=GenerateInvertedIndexScans
SELECT k FROM b@j_inv_idx WHERE jsonb_path_exists(j, '$.a.b')
----
project
├── columns: k:1!null
├── immutable
├── key: (1)
└── inverted-filter
├── columns: k:1!null
├── inverted expression: /9
│ ├── tight: true, unique: false
│ └── union spans
│ ├── ["a"/Arr/b???, "a"/Arr/Arr/)
│ └── ["a"/b???, "a"/Arr/)
├── key: (1)
└── scan b@j_inv_idx,inverted
├── columns: k:1!null j_inverted_key:9!null
├── inverted constraint: /9/1
│ └── spans
│ ├── ["a"/Arr/b???, "a"/Arr/Arr/)
│ └── ["a"/b???, "a"/Arr/)
└── flags: force-index=j_inv_idx
```

Jira issue: CRDB-54955

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.