Skip to content

Conversation

@blathers-crl
Copy link

@blathers-crl blathers-crl bot commented Nov 5, 2025

Backport 1/1 commits from #156828 on behalf of @ZhouXing19.


Fixes: #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.


Release justification: bug fix.

@blathers-crl blathers-crl bot requested a review from a team as a code owner November 5, 2025 21:17
@blathers-crl blathers-crl bot requested review from yuzefovich and removed request for a team November 5, 2025 21:17
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Nov 5, 2025
@blathers-crl blathers-crl bot requested review from ZhouXing19 and mgartner November 5, 2025 21:17
@blathers-crl
Copy link
Author

blathers-crl bot commented Nov 5, 2025

Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Nov 5, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich yuzefovich requested review from michae2 and removed request for ZhouXing19, mgartner and yuzefovich November 11, 2025 02:14
Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm:

@michae2 reviewed 2 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ZhouXing19)

Fixes: #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.
@ZhouXing19 ZhouXing19 force-pushed the blathers/backport-release-25.4-156828 branch from 430fb70 to 8796b21 Compare November 11, 2025 15:31
@ZhouXing19 ZhouXing19 merged commit a96be29 into release-25.4 Nov 11, 2025
15 checks passed
@ZhouXing19 ZhouXing19 deleted the blathers/backport-release-25.4-156828 branch November 11, 2025 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team target-release-25.4.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants