1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

doc: reformat GRAPH_TABLE examples

The GRAPH_TABLE examples in ddl.sgml and queries.sgml were written
as single long lines, making their structure harder to read in the
generated documentation.

Reformat these examples so that the graph name, MATCH clause, and
COLUMNS clause appear on separate lines, making them easier to read.

Author: Koshino Taiki <koshino@sraoss.co.jp>
Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/OS9P286MB64860BD6CD6D4B4B0E1CEDE894A32@OS9P286MB6486.JPNP286.PROD.OUTLOOK.COM
Backpatch-through: 19
This commit is contained in:
Fujii Masao
2026-09-01 12:54:31 +09:00
parent 3b120b1e94
commit a20d3e35f2
2 changed files with 18 additions and 7 deletions

View File

@@ -5808,7 +5808,9 @@ CREATE PROPERTY GRAPH myshop
This graph could then be queried like this: This graph could then be queried like this:
<programlisting> <programlisting>
-- get list of customers active today -- get list of customers active today
SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name)); SELECT customer_name FROM GRAPH_TABLE (myshop
MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date)
COLUMNS (c.name AS customer_name));
</programlisting> </programlisting>
corresponding approximately to this relational query: corresponding approximately to this relational query:
<programlisting> <programlisting>
@@ -5872,7 +5874,9 @@ CREATE PROPERTY GRAPH myshop
<para> <para>
With this definition, we can write a query like this: With this definition, we can write a query like this:
<programlisting> <programlisting>
SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customer)-[IS has_placed]->(o IS "order" WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name)); SELECT customer_name FROM GRAPH_TABLE (myshop
MATCH (c IS customer)-[IS has_placed]->(o IS "order" WHERE o.ordered_when = current_date)
COLUMNS (c.name AS customer_name));
</programlisting> </programlisting>
With the new labels the <literal>MATCH</literal> clause is now more intuitive. With the new labels the <literal>MATCH</literal> clause is now more intuitive.
</para> </para>
@@ -5911,7 +5915,9 @@ CREATE PROPERTY GRAPH myshop
<literal>employees</literal> table to something, but it is allowed like <literal>employees</literal> table to something, but it is allowed like
this.) Then we can run a query like this (incomplete): this.) Then we can run a query like this (incomplete):
<programlisting> <programlisting>
SELECT ... FROM GRAPH_TABLE (myshop MATCH (IS person WHERE name = '...')-[]->... COLUMNS (...)); SELECT ... FROM GRAPH_TABLE (myshop
MATCH (IS person WHERE name = '...')-[]->...
COLUMNS (...));
</programlisting> </programlisting>
This would automatically consider both the <literal>customers</literal> and This would automatically consider both the <literal>customers</literal> and
the <literal>employees</literal> tables when looking for an edge with the the <literal>employees</literal> tables when looking for an edge with the

View File

@@ -2768,7 +2768,9 @@ SELECT * FROM t;
Consider this example from <xref linkend="ddl-property-graphs"/>: Consider this example from <xref linkend="ddl-property-graphs"/>:
<programlisting> <programlisting>
-- get list of customers active today -- get list of customers active today
SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date) COLUMNS (c.name AS customer_name)); SELECT customer_name FROM GRAPH_TABLE (myshop
MATCH (c IS customers)-[IS customer_orders]->(o IS orders WHERE o.ordered_when = current_date)
COLUMNS (c.name AS customer_name));
</programlisting> </programlisting>
The graph query part happens inside the <literal>GRAPH_TABLE</literal> The graph query part happens inside the <literal>GRAPH_TABLE</literal>
construct. As far as the rest of the query is concerned, this acts like a construct. As far as the rest of the query is concerned, this acts like a
@@ -2777,7 +2779,9 @@ SELECT customer_name FROM GRAPH_TABLE (myshop MATCH (c IS customers)-[IS custome
names can be assigned to the result, and the result can be joined with names can be assigned to the result, and the result can be joined with
other tables, subsequently filtered, and so on, for example: other tables, subsequently filtered, and so on, for example:
<programlisting> <programlisting>
SELECT ... FROM GRAPH_TABLE (mygraph MATCH ... COLUMNS (...)) AS myresult (a, b, c) JOIN othertable USING (a) WHERE b > 0 ORDER BY c; SELECT ... FROM GRAPH_TABLE (mygraph
MATCH ...
COLUMNS (...)) AS myresult (a, b, c) JOIN othertable USING (a) WHERE b > 0 ORDER BY c;
</programlisting> </programlisting>
</para> </para>
@@ -2893,8 +2897,9 @@ SELECT ... FROM GRAPH_TABLE (mygraph MATCH ... COLUMNS (...)) AS myresult (a, b,
For example (assuming appropriate definitions of the property graph as For example (assuming appropriate definitions of the property graph as
well as the underlying tables): well as the underlying tables):
<programlisting> <programlisting>
GRAPH_TABLE (mygraph MATCH (p IS person)-[h IS has]->(a IS account) GRAPH_TABLE (mygraph
COLUMNS (p.name AS person_name, h.since AS has_account_since, a.num AS account_number) MATCH (p IS person)-[h IS has]->(a IS account)
COLUMNS (p.name AS person_name, h.since AS has_account_since, a.num AS account_number))
</programlisting> </programlisting>
<literal>WHERE</literal> clauses can be used inside element patterns to <literal>WHERE</literal> clauses can be used inside element patterns to
filter matches: filter matches: