@@ -11538,7 +11538,8 @@ table2-mapping
11538
11538
from the JSON data, similar to XPath expressions used
11539
11539
for SQL access to XML. In <productname>PostgreSQL</productname>,
11540
11540
path expressions are implemented as the <type>jsonpath</type>
11541
- data type, described in <xref linkend="datatype-jsonpath"/>.
11541
+ data type and can use any elements described in
11542
+ <xref linkend="datatype-jsonpath"/>.
11542
11543
</para>
11543
11544
11544
11545
<para>JSON query functions and operators
@@ -11585,7 +11586,7 @@ table2-mapping
11585
11586
},
11586
11587
{ "location": [ 47.706, 13.2635 ],
11587
11588
"start time": "2018-10-14 10:39:21",
11588
- "HR": 130
11589
+ "HR": 135
11589
11590
} ]
11590
11591
}
11591
11592
}
@@ -11637,23 +11638,33 @@ table2-mapping
11637
11638
11638
11639
<para>
11639
11640
When defining the path, you can also use one or more
11640
- <firstterm>filter expressions</firstterm>, which work similar to
11641
- the <literal>WHERE</literal> clause in SQL. Each filter expression
11642
- can provide one or more filtering conditions that are applied
11643
- to the result of the path evaluation. Each filter expression must
11644
- be enclosed in parentheses and preceded by a question mark.
11645
- Filter expressions are evaluated from left to right and can be nested.
11646
- The <literal>@</literal> variable denotes the current path evaluation
11647
- result to be filtered, and can be followed by one or more accessor
11648
- operators to define the JSON element by which to filter the result.
11649
- Functions and operators that can be used in the filtering condition
11650
- are listed in <xref linkend="functions-sqljson-filter-ex-table"/>.
11651
- SQL/JSON defines three-valued logic, so the result of the filter
11652
- expression may be <literal>true</literal>, <literal>false</literal>,
11641
+ <firstterm>filter expressions</firstterm> that work similar to the
11642
+ <literal>WHERE</literal> clause in SQL. A filter expression begins with
11643
+ a question mark and provides a condition in parentheses:
11644
+
11645
+ <programlisting>
11646
+ ? (<replaceable>condition</replaceable>)
11647
+ </programlisting>
11648
+ </para>
11649
+
11650
+ <para>
11651
+ Filter expressions must be specified right after the path evaluation step
11652
+ to which they are applied. The result of this step is filtered to include
11653
+ only those items that satisfy the provided condition. SQL/JSON defines
11654
+ three-valued logic, so the condition can be <literal>true</literal>, <literal>false</literal>,
11653
11655
or <literal>unknown</literal>. The <literal>unknown</literal> value
11654
- plays the same role as SQL <literal>NULL</literal>. Further path
11656
+ plays the same role as SQL <literal>NULL</literal> and can be tested
11657
+ for with the <literal>is unknown</literal> predicate. Further path
11655
11658
evaluation steps use only those items for which filter expressions
11656
- return true.
11659
+ return <literal>true</literal>.
11660
+ </para>
11661
+
11662
+ <para>
11663
+ Functions and operators that can be used in filter expressions are listed
11664
+ in <xref linkend="functions-sqljson-filter-ex-table"/>. The path
11665
+ evaluation result to be filtered is denoted by the <literal>@</literal>
11666
+ variable. To refer to a JSON element stored at a lower nesting level,
11667
+ add one or more accessor operators after <literal>@</literal>.
11657
11668
</para>
11658
11669
11659
11670
<para>
@@ -11667,8 +11678,8 @@ table2-mapping
11667
11678
<para>
11668
11679
To get the start time of segments with such values instead, you have to
11669
11680
filter out irrelevant segments before returning the start time, so the
11670
- filter is applied to the previous step and the path in the filtering
11671
- condition is different:
11681
+ filter expression is applied to the previous step, and the path used
11682
+ in the condition is different:
11672
11683
<programlisting>
11673
11684
'$.track.segments[*] ? (@.HR > 130)."start time"'
11674
11685
</programlisting>
@@ -11693,9 +11704,9 @@ table2-mapping
11693
11704
</para>
11694
11705
11695
11706
<para>
11696
- You can also nest filters within each other:
11707
+ You can also nest filter expressions within each other:
11697
11708
<programlisting>
11698
- '$.track ? (@.segments[*] ? (@.HR > 130)).segments.size()'
11709
+ '$.track ? (exists( @.segments[*] ? (@.HR > 130) )).segments.size()'
11699
11710
</programlisting>
11700
11711
This expression returns the size of the track if it contains any
11701
11712
segments with high heart rate values, or an empty sequence otherwise.
@@ -12285,7 +12296,7 @@ table2-mapping
12285
12296
<row>
12286
12297
<entry><literal>@?</literal></entry>
12287
12298
<entry><type>jsonpath</type></entry>
12288
- <entry>Does JSON path returns any item for the specified JSON value?</entry>
12299
+ <entry>Does JSON path return any item for the specified JSON value?</entry>
12289
12300
<entry><literal>'{"a":[1,2,3,4,5]}'::jsonb @? '$.a[*] ? (@ > 2)'</literal></entry>
12290
12301
</row>
12291
12302
<row>
@@ -12313,8 +12324,8 @@ table2-mapping
12313
12324
<note>
12314
12325
<para>
12315
12326
The <literal>@?</literal> and <literal>@@</literal> operators suppress
12316
- errors including : lacking object field or array element, unexpected JSON
12317
- item type and numeric errors.
12327
+ the following errors : lacking object field or array element, unexpected
12328
+ JSON item type, and numeric errors.
12318
12329
This behavior might be helpful while searching over JSON document
12319
12330
collections of varying structure.
12320
12331
</para>
@@ -13170,17 +13181,17 @@ table2-mapping
13170
13181
<literal>jsonb_path_query</literal>, <literal>jsonb_path_query_array</literal> and
13171
13182
<literal>jsonb_path_query_first</literal>
13172
13183
functions have optional <literal>vars</literal> and <literal>silent</literal>
13173
- argument .
13184
+ arguments .
13174
13185
</para>
13175
13186
<para>
13176
- When <literal>vars</literal> argument is specified, it constitutes an object
13177
- contained variables to be substituted into <literal>jsonpath</literal>
13178
- expression.
13187
+ If the <literal>vars</literal> argument is specified, it provides an
13188
+ object containing named variables to be substituted into a
13189
+ <literal>jsonpath</literal> expression.
13179
13190
</para>
13180
13191
<para>
13181
- When <literal>silent</literal> argument is specified and has
13182
- <literal>true</literal> value, the same errors are suppressed as it is in
13183
- the <literal>@?</literal> and <literal>@@</literal> operators.
13192
+ If the <literal>silent</literal> argument is specified and has the
13193
+ <literal>true</literal> value, these functions suppress the same errors
13194
+ as the <literal>@?</literal> and <literal>@@</literal> operators.
13184
13195
</para>
13185
13196
</note>
13186
13197
0 commit comments