Commit f79b842
Merge cockroachdb#156828
156828: sql/jsonpath: unwrap array with root key for index acceleration r=ZhouXing19 a=ZhouXing19
Fixes: cockroachdb#156741
Previously, we didn't consider the case where the queried JSON is an array and the root key can unwrap one layer of the array.
For example:
```
INSERT INTO json_tab VALUES (1,'[{"b": {"x": "y"}, "a": "x"}, null]');
CREATE INVERTED INDEX foo_inv ON json_tab(b);
SELECT a FROM json_tab@foo_inv WHERE jsonb_path_exists(b, '$.b');
```
This previously returned an empty result but should return 1.
This commit fixes the issue by adding array-unwrapping for the root key (`$`).
Release note (bug fix): Fix JSON path index acceleration with JSON array objects. Only 25.4.0 releases are affected.
Co-authored-by: ZhouXing19 <[email protected]>File tree
4 files changed
+195
-71
lines changed- pkg
- sql
- logictest/testdata/logic_test
- opt
- exec/execbuilder/testdata
- xform/testdata/rules
- util/jsonpath
4 files changed
+195
-71
lines changedLines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
560 | 585 | | |
561 | 586 | | |
562 | 587 | | |
| |||
0 commit comments