Skip to content

Commit 332bab6

Browse files
Fix glossary errors (#1007)
## Goal We fix glossary and corresponding pages with missing and incorrectly documented operators.
1 parent 1ce8eed commit 332bab6

File tree

6 files changed

+139
-8
lines changed

6 files changed

+139
-8
lines changed

typeql-reference/modules/ROOT/pages/expressions/operators.adoc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,49 @@ Parentheses (`()`) may be used to override the precedence. The sub-expressions i
2626
----
2727
(1 + 2) * 3 == 9
2828
----
29+
30+
== Built-in functions
31+
32+
TypeQL provides several built-in functions for common mathematical and list operations:
33+
34+
=== Mathematical functions
35+
36+
`round(x)`::
37+
Returns the provided numeric argument rounded to the nearest integer.
38+
39+
[,typeql]
40+
----
41+
round(3.7) == 4
42+
round(3.2) == 3
43+
round(-3.7) == -4
44+
----
45+
46+
`ceil(x)`::
47+
Returns the provided numeric argument rounded to the nearest greater integer (ceiling).
48+
49+
[,typeql]
50+
----
51+
ceil(3.2) == 4
52+
ceil(3.7) == 4
53+
ceil(-3.2) == -3
54+
----
55+
56+
`floor(x)`::
57+
Returns the provided numeric argument rounded to the nearest lesser integer (floor).
58+
59+
[,typeql]
60+
----
61+
floor(3.2) == 3
62+
floor(3.7) == 3
63+
floor(-3.2) == -4
64+
----
65+
66+
`abs(x)`::
67+
Returns the absolute value of the provided numeric argument.
68+
69+
[,typeql]
70+
----
71+
abs(5) == 5
72+
abs(-5) == 5
73+
abs(0) == 0
74+
----

typeql-reference/modules/ROOT/pages/keywords.adoc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ Denotes the beginning of a xref:{page-version}@typeql-reference::pipelines/put.a
3939
Denotes the beginning of a xref:{page-version}@typeql-reference::pipelines/select.adoc[] in a data pipeline, used to keep specified variables for each element of the data stream and remove the rest.
4040

4141
`require`::
42-
Denotes the beginning of a xref:{page-version}@typeql-reference::pipelines/require.adoc[] in a data pipeline, used to remove elements from the data stream that do not contain specified optional variables.
42+
Denotes the beginning of a xref:{page-version}@typeql-reference::pipelines/require.adoc[Require operator] in a data pipeline, used to remove elements from the data stream that do not contain specified optional variables.
43+
44+
`distinct`::
45+
Denotes the beginning of a xref:{page-version}@typeql-reference::pipelines/distinct.adoc[Distinct operator] in a data pipeline, used to remove duplicate elements from the data stream.
4346

4447
`sort`::
4548
Denotes the beginning of a xref:{page-version}@typeql-reference::pipelines/sort.adoc[] in a data pipeline, used to order the elements of the data stream based on the value of specified variables.
@@ -185,12 +188,6 @@ Describes a xref:{page-version}@typeql-reference::annotations/distinct.adoc[], u
185188

186189
== Reductions
187190

188-
`check`::
189-
Reduces the stream to a boolean value, indicating whether it contains any elements. See xref:{page-version}@typeql-reference::pipelines/reduce.adoc[] for more information.
190-
191-
`first`::
192-
Reduces the stream to the first occurrence of a specified variable. See xref:{page-version}@typeql-reference::pipelines/reduce.adoc[] for more information.
193-
194191
`count`::
195192
Reduces the stream to the number of occurrences of a specified variable. See xref:{page-version}@typeql-reference::pipelines/reduce.adoc[] for more information.
196193

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
= Distinct operator
2+
:test-typeql: linear
3+
4+
The distinct operator removes duplicate elements from the data stream. Elements are considered duplicates if all their variables have the same values.
5+
6+
== Syntax
7+
8+
[,typeql]
9+
----
10+
distinct;
11+
----
12+
13+
== Example
14+
15+
.Schema for the following examples
16+
[%collapsible]
17+
====
18+
[,typeql]
19+
----
20+
#!test[schema, commit]
21+
include::{page-version}@reference::example$tql/schema_statements_functions.tql[tags=define-keyword;entities;attributes;relation-friendship]
22+
----
23+
====
24+
25+
Find all unique ages of users:
26+
27+
[,typeql]
28+
----
29+
#!test[read]
30+
match
31+
$user isa user, has age $age;
32+
select $age;
33+
distinct;
34+
----
35+
36+
Remove duplicate answers that may result from using `or` patterns:
37+
38+
[,typeql]
39+
----
40+
#!test[read]
41+
match
42+
{ $p isa person; } or { $p has name "John"; };
43+
distinct; # Make sure that the person with name John is returned at most once.
44+
----
45+

typeql-reference/modules/ROOT/pages/pipelines/index.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Used to keep specified variables for each element of the data stream and remove
6969
Used to remove elements from the data stream that do not contain specified optional variables.
7070
****
7171

72+
.xref:{page-version}@typeql-reference::pipelines/distinct.adoc[]
73+
[.clickable]
74+
****
75+
Used to remove duplicate elements from the data stream.
76+
****
77+
7278
.xref:{page-version}@typeql-reference::pipelines/sort.adoc[]
7379
[.clickable]
7480
****
Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1-
= Require stage
1+
= Require operator
2+
:test-typeql: linear
3+
4+
The require operator filters the data stream to only include elements that contain the specified variables. Elements where any of the specified variables are unbound (empty) are removed from the stream.
5+
6+
== Syntax
7+
8+
[,typeql]
9+
----
10+
require <var> [ , <var> ... ];
11+
----
12+
13+
== Example
14+
15+
.Schema for the following examples
16+
[%collapsible]
17+
====
18+
[,typeql]
19+
----
20+
#!test[schema, commit]
21+
include::{page-version}@reference::example$tql/schema_statements_functions.tql[tags=define-keyword;entities;attributes;relation-friendship]
22+
----
23+
====
24+
25+
Find users who have both a username and an email address:
26+
27+
[,typeql]
28+
----
29+
#!test[read]
30+
match
31+
$user isa user;
32+
try { $user has username $username; };
33+
try { $user has email $email; };
34+
require $username, $email;
35+
----
36+
37+
In this example, the `try` clauses make `$username` and `$email` optional. The `require` operator then filters the stream to only include users who have both attributes bound (note: in this example, it would have been equivalent to not use `try` clauses and skip the `require` clause!)

typeql-reference/modules/ROOT/partials/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
** xref:{page-version}@typeql-reference::pipelines/put.adoc[Put]
1515
** xref:{page-version}@typeql-reference::pipelines/select.adoc[Select]
1616
** xref:{page-version}@typeql-reference::pipelines/require.adoc[Require]
17+
** xref:{page-version}@typeql-reference::pipelines/distinct.adoc[Distinct]
1718
** xref:{page-version}@typeql-reference::pipelines/sort.adoc[Sort]
1819
** xref:{page-version}@typeql-reference::pipelines/limit.adoc[Limit]
1920
** xref:{page-version}@typeql-reference::pipelines/offset.adoc[Offset]

0 commit comments

Comments
 (0)