Optimizing layout
Pull request merged

jsonpath: add jsonpath conditional evaluation

jsonpath: add jsonpath conditional evaluation

This commit adds support for evaluating jsonpath conditionals.
Conditionals have the structure of $ ? (predicate), and will filter
the current json objects based on whether they satisfy the predicate
expression. Additionally, this commit introduces @, which represents
the current json object so filters can be used to reference the object
being evaluated.

Informs: #142610
Epic: None
Release note (sql change): Add jsonpath filters, which take on the form
$ ? (predicate), allowing results to be filtered.

jsonpath/eval: add unwrap parameter to jsonpath.eval

Previously, jsonpath conditionals/filters would unwrap infinitely. For
example, SELECT jsonb_path_query('{"a": [[[[{"b": 1}]]]]}', '$.a ? (@.b == 1)');
would return an entry, when postgres would not. This commit adds an
unwrap boolean parameter to eval, which allows for control over when
to stop unwrapping json arrays. Additionally, this commit updates
eval to take in a json.JSON rather than a []json.JSON, simplifying
the evaluation logic.

Epic: None
Release note: None

see less
File matrix
13 files13 files
r1
r2
r3
r4
r1
r2
r3
r4
pkg/pkg/
sql/scanner/sql/scanner/
r1
r2
r3
r4
util/jsonpath/util/jsonpath/
r1
r2
r3
r4
eval/eval/
r2
r3
r4
r1
r2
r3
r4
r1
r2
r3
r4
r1
r2
r3
r4
r2
r3
r4
r1
r2
r3
r4
r2
r3
r4
parser/parser/
r1
r2
r3
r4
Test Data
pkg/pkg/
sql/logictest/testdata/logic_test/sql/logictest/testdata/logic_test/
r1
r2
r3
r4
util/jsonpath/parser/testdata/util/jsonpath/parser/testdata/
r1
r2
r3
r4
+41
+41
±0%
adjust what's shown in the file matrix here.
Participants
waiting on
participant
status
role
contributor
last active
drafts
discussions
Diffs
  Reviewing the latest revision (r4) against its ⊥ base revision.

Next diffs to review (file selection:

)

Show other diffs: All changes

Preferences
Top level discussions
Review discussion
1 week ago
New comments
yuzefovichYahor Yuzefovich

Very nice! I only have a handful of nits.

1 week ago
yuzefovichYahor Yuzefovich

Thanks! :lgtm:

1 week ago
normanchennNorman Chen

TFTR!

bors r+

r1
r2
r3
r4
+41
Revision mapping:
Compact 4 revisions Click and hold to arm, release to activate.
r1
r2
r3
r4
r1
r2
r3
r4
r2
r3
r4
r1
r2
r3
r4
r1
r2
r3
r4
r1
r2
r3
r4
r2
r3
r4
r1
r2
r3
r4
r2
r3
r4
r1
r2
r3
r4
r1
r2
r3
r4
r1
r2
r3
r4
Use of Reviewable is subject to the terms of useprivacy policy.