You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
144006: builtins: add `jsonb_path_query_array`, `jsonb_path_query_first`, `jsonb_path_match` r=normanchenn a=normanchenn
#### builtins: add jsonb_path_query_array
This commit adds the `jsonb_path_query_array` function, which wraps
`jsonb_path_query` and returns a json array containing all the items
returned from the query.
Informs: #22513
Release note (sql change): Add the `jsonb_path_query_array` function,
which returns the result of `jsonb_path_query` wrapped in a JSON array.
#### builtins: add jsonb_path_query_first
This commit adds the `jsonb_path_query_first` function, which wraps
`jsonb_path_query` and returns the first element that was returned from
the function.
Informs: #22513
Release note (sql change): Add the `jsonb_path_query_first` function,
which returns the first result from `jsonb_path_query`.
#### builtins: add jsonb_path_match
This commit adds the `jsonb_path_match` function, which returns a
boolean that evaluates the predicate query, and returns null if the
query result isn't a predicate.
Informs: #22513
Release note (sql change): Add the `jsonb_path_match` function, which
returns the result of a predicate query.
Co-authored-by: Norman Chen <[email protected]>
Copy file name to clipboardExpand all lines: docs/generated/sql/functions.md
+53Lines changed: 53 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1280,6 +1280,29 @@ argument is true, the function suppresses the following errors:
1280
1280
missing object field or array element, unexpected JSON item type,
1281
1281
datetime and numeric errors.</p>
1282
1282
</span></td><td>Immutable</td></tr>
1283
+
<tr><td><aname="jsonb_path_match"></a><code>jsonb_path_match(target: jsonb, path: jsonpath) → <ahref="bool.html">bool</a></code></td><td><spanclass="funcdesc"><p>Returns the SQL boolean result of a JSON path predicate check
1284
+
for the specified JSON value. (This is useful only with predicate check
1285
+
expressions, not SQL-standard JSON path expressions, since it will
1286
+
either fail or return NULL if the path result is not a single boolean
1287
+
value.)</p>
1288
+
</span></td><td>Immutable</td></tr>
1289
+
<tr><td><aname="jsonb_path_match"></a><code>jsonb_path_match(target: jsonb, path: jsonpath, vars: jsonb) → <ahref="bool.html">bool</a></code></td><td><spanclass="funcdesc"><p>Returns the SQL boolean result of a JSON path predicate check
1290
+
for the specified JSON value. (This is useful only with predicate check
1291
+
expressions, not SQL-standard JSON path expressions, since it will
1292
+
either fail or return NULL if the path result is not a single boolean
1293
+
value.) The vars argument must be a JSON object, and its fields provide
1294
+
named values to be substituted into the jsonpath expression.</p>
1295
+
</span></td><td>Immutable</td></tr>
1296
+
<tr><td><aname="jsonb_path_match"></a><code>jsonb_path_match(target: jsonb, path: jsonpath, vars: jsonb, silent: <ahref="bool.html">bool</a>) → <ahref="bool.html">bool</a></code></td><td><spanclass="funcdesc"><p>Returns the SQL boolean result of a JSON path predicate check
1297
+
for the specified JSON value. (This is useful only with predicate check
1298
+
expressions, not SQL-standard JSON path expressions, since it will
1299
+
either fail or return NULL if the path result is not a single boolean
1300
+
value.) The vars argument must be a JSON object, and its fields provide
1301
+
named values to be substituted into the jsonpath expression. If the
1302
+
silent argument is true, the function suppresses the following errors:
1303
+
missing object field or array element, unexpected JSON item type,
1304
+
datetime and numeric errors.</p>
1305
+
</span></td><td>Immutable</td></tr>
1283
1306
<tr><td><aname="jsonb_path_query"></a><code>jsonb_path_query(target: jsonb, path: jsonpath) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns all JSON items returned by the JSON path for the specified JSON value.</p>
1284
1307
</span></td><td>Immutable</td></tr>
1285
1308
<tr><td><aname="jsonb_path_query"></a><code>jsonb_path_query(target: jsonb, path: jsonpath, vars: jsonb) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns all JSON items returned by the JSON path for the specified JSON value.
@@ -1291,6 +1314,36 @@ The vars argument must be a JSON object, and its fields provide named values
1291
1314
to be substituted into the jsonpath expression. If the silent argument is true,
1292
1315
the function suppresses the following errors: missing object field or array
1293
1316
element, unexpected JSON item type, datetime and numeric errors.</p>
1317
+
</span></td><td>Immutable</td></tr>
1318
+
<tr><td><aname="jsonb_path_query_array"></a><code>jsonb_path_query_array(target: jsonb, path: jsonpath) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns all JSON items returned by the JSON path for the
1319
+
specified JSON value, as a JSON array.</p>
1320
+
</span></td><td>Immutable</td></tr>
1321
+
<tr><td><aname="jsonb_path_query_array"></a><code>jsonb_path_query_array(target: jsonb, path: jsonpath, vars: jsonb) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns all JSON items returned by the JSON path for the
1322
+
specified JSON value, as a JSON array. The vars argument must be a
1323
+
JSON object, and its fields provide named values to be substituted
1324
+
into the jsonpath expression.</p>
1325
+
</span></td><td>Immutable</td></tr>
1326
+
<tr><td><aname="jsonb_path_query_array"></a><code>jsonb_path_query_array(target: jsonb, path: jsonpath, vars: jsonb, silent: <ahref="bool.html">bool</a>) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns all JSON items returned by the JSON path for the
1327
+
specified JSON value, as a JSON array. The vars argument must be a
1328
+
JSON object, and its fields provide named values to be substituted
1329
+
into the jsonpath expression. If the silent argument is true, the
1330
+
function suppresses the following errors: missing object field or
1331
+
array element, unexpected JSON item type, datetime and numeric errors.</p>
1332
+
</span></td><td>Immutable</td></tr>
1333
+
<tr><td><aname="jsonb_path_query_first"></a><code>jsonb_path_query_first(target: jsonb, path: jsonpath) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns the first JSON item returned by the JSON path for the
1334
+
specified JSON value, or NULL if there are no results.</p>
1335
+
</span></td><td>Immutable</td></tr>
1336
+
<tr><td><aname="jsonb_path_query_first"></a><code>jsonb_path_query_first(target: jsonb, path: jsonpath, vars: jsonb) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns the first JSON item returned by the JSON path for the
1337
+
specified JSON value, or NULL if there are no results. The vars
1338
+
argument must be a JSON object, and its fields provide named values
1339
+
to be substituted into the jsonpath expression.</p>
1340
+
</span></td><td>Immutable</td></tr>
1341
+
<tr><td><aname="jsonb_path_query_first"></a><code>jsonb_path_query_first(target: jsonb, path: jsonpath, vars: jsonb, silent: <ahref="bool.html">bool</a>) → jsonb</code></td><td><spanclass="funcdesc"><p>Returns the first JSON item returned by the JSON path for the
1342
+
specified JSON value, or NULL if there are no results. The vars
1343
+
argument must be a JSON object, and its fields provide named values
1344
+
to be substituted into the jsonpath expression. If the silent argument is true, the
1345
+
function suppresses the following errors: missing object field or
1346
+
array element, unexpected JSON item type, datetime and numeric errors.</p>
0 commit comments