Skip to content

Commit

Permalink
[#5408] [YSQL] Improve documentation for array subscription in jsonpath
Browse files Browse the repository at this point in the history
Summary:
Original commit was 87bcc02f4f739d76703feee0ff8346b98fa9b907

Commit message was

    Usage of expressions and multiple ranges in jsonpath array subscription was
    undocumented.  This commit adds lacking documentation.

Test Plan: Build yugabyte and run test.

Reviewers: mihnea, jason

Reviewed By: jason

Subscribers: yql

Differential Revision: https://phabricator.dev.yugabyte.com/D9460
  • Loading branch information
tedyu committed Sep 24, 2020
1 parent e50b588 commit 125f300
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/postgres/doc/src/sgml/json.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -836,17 +836,22 @@ SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @> '{"tags": ["qu
<para>
<literal>[<replaceable>subscript</replaceable>, ...]</literal>
</para>
<para>
<literal>[<replaceable>subscript</replaceable> to last]</literal>
</para>
</entry>
<entry>
<para>
Array element accessor. The provided numeric subscripts return the
corresponding array elements. The first element in an array is
accessed with [0]. The <literal>last</literal> keyword denotes
the last subscript in an array and can be used to handle arrays
of unknown length.
Array element accessor. <literal><replaceable>subscript</replaceable></literal>
might be given in two forms: <literal><replaceable>expr</replaceable></literal>
or <literal><replaceable>lower_expr</replaceable> to <replaceable>upper_expr</replaceable></literal>.
The first form specifies single array element by its index. The second
form specified array slice by the range of indexes. Zero index
corresponds to the first array element.
</para>
<para>
Expression inside subscript may consititue an integer,
numeric expression or any other <literal>jsonpath</literal> expression
returning single numeric value. The <literal>last</literal> keyword
can be used in the expression denoting the last subscript in an array.
That's helpful for handling arrays of unknown length.
</para>
</entry>
</row>
Expand Down

0 comments on commit 125f300

Please sign in to comment.