Skip to content

Commit 9143a44

Browse files
authored
[Doc] Enable doctest with Calcite (#4379)
1 parent a6d5626 commit 9143a44

File tree

8 files changed

+237
-278
lines changed

8 files changed

+237
-278
lines changed

docs/category.json

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,9 @@
77
"user/admin/settings.rst"
88
],
99
"ppl_cli": [
10-
"user/ppl/cmd/ad.rst",
11-
"user/ppl/cmd/dedup.rst",
12-
"user/ppl/cmd/describe.rst",
13-
"user/ppl/cmd/showdatasources.rst",
14-
"user/ppl/cmd/eval.rst",
15-
"user/ppl/cmd/fillnull.rst",
1610
"user/ppl/cmd/grok.rst",
17-
"user/ppl/cmd/head.rst",
1811
"user/ppl/cmd/parse.rst",
19-
"user/ppl/cmd/patterns.rst",
20-
"user/ppl/cmd/rare.rst",
21-
"user/ppl/cmd/search.rst",
22-
"user/ppl/cmd/sort.rst",
23-
"user/ppl/cmd/syntax.rst",
24-
"user/ppl/cmd/trendline.rst",
25-
"user/ppl/cmd/top.rst",
26-
"user/ppl/cmd/where.rst",
27-
"user/ppl/cmd/join.rst",
28-
"user/ppl/cmd/lookup.rst",
29-
"user/ppl/cmd/subquery.rst",
30-
"user/ppl/general/identifiers.rst",
31-
"user/ppl/general/datatypes.rst",
32-
"user/ppl/functions/datetime.rst",
33-
"user/ppl/functions/expressions.rst",
34-
"user/ppl/functions/ip.rst",
35-
"user/ppl/functions/json.rst",
36-
"user/ppl/functions/math.rst",
37-
"user/ppl/functions/relevance.rst",
38-
"user/ppl/functions/string.rst"
12+
"user/ppl/cmd/patterns.rst"
3913
],
4014
"sql_cli": [
4115
"user/dql/expressions.rst",
@@ -52,16 +26,41 @@
5226
"user/dql/metadata.rst"
5327
],
5428
"ppl_cli_calcite": [
29+
"user/ppl/cmd/ad.rst",
5530
"user/ppl/cmd/append.rst",
5631
"user/ppl/cmd/bin.rst",
57-
"user/ppl/functions/condition.rst",
32+
"user/ppl/cmd/dedup.rst",
33+
"user/ppl/cmd/describe.rst",
5834
"user/ppl/cmd/eventstats.rst",
35+
"user/ppl/cmd/eval.rst",
5936
"user/ppl/cmd/fields.rst",
37+
"user/ppl/cmd/fillnull.rst",
38+
"user/ppl/cmd/head.rst",
39+
"user/ppl/cmd/join.rst",
40+
"user/ppl/cmd/lookup.rst",
41+
"user/ppl/cmd/rare.rst",
6042
"user/ppl/cmd/regex.rst",
6143
"user/ppl/cmd/rename.rst",
6244
"user/ppl/cmd/rex.rst",
45+
"user/ppl/cmd/search.rst",
46+
"user/ppl/cmd/showdatasources.rst",
47+
"user/ppl/cmd/sort.rst",
6348
"user/ppl/cmd/stats.rst",
49+
"user/ppl/cmd/subquery.rst",
50+
"user/ppl/cmd/syntax.rst",
6451
"user/ppl/cmd/timechart.rst",
65-
"user/ppl/cmd/search.rst"
52+
"user/ppl/cmd/top.rst",
53+
"user/ppl/cmd/trendline.rst",
54+
"user/ppl/cmd/where.rst",
55+
"user/ppl/functions/condition.rst",
56+
"user/ppl/functions/datetime.rst",
57+
"user/ppl/functions/expressions.rst",
58+
"user/ppl/functions/ip.rst",
59+
"user/ppl/functions/json.rst",
60+
"user/ppl/functions/math.rst",
61+
"user/ppl/functions/relevance.rst",
62+
"user/ppl/functions/string.rst",
63+
"user/ppl/general/datatypes.rst",
64+
"user/ppl/general/identifiers.rst"
6665
]
6766
}

docs/user/ppl/cmd/dedup.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The example show dedup the document with gender field.
3232

3333
PPL query::
3434

35-
os> source=accounts | dedup gender | fields account_number, gender;
35+
os> source=accounts | dedup gender | fields account_number, gender | sort account_number;
3636
fetched rows / total rows = 2/2
3737
+----------------+--------+
3838
| account_number | gender |
@@ -48,7 +48,7 @@ The example show dedup the document with gender field keep 2 duplication.
4848

4949
PPL query::
5050

51-
os> source=accounts | dedup 2 gender | fields account_number, gender;
51+
os> source=accounts | dedup 2 gender | fields account_number, gender | sort account_number;
5252
fetched rows / total rows = 3/3
5353
+----------------+--------+
5454
| account_number | gender |
@@ -65,7 +65,7 @@ The example show dedup the document by keep null value field.
6565

6666
PPL query::
6767

68-
os> source=accounts | dedup email keepempty=true | fields account_number, email;
68+
os> source=accounts | dedup email keepempty=true | fields account_number, email | sort account_number;
6969
fetched rows / total rows = 4/4
7070
+----------------+-----------------------+
7171
| account_number | email |
@@ -81,7 +81,7 @@ The example show dedup the document by ignore the empty value field.
8181

8282
PPL query::
8383

84-
os> source=accounts | dedup email | fields account_number, email;
84+
os> source=accounts | dedup email | fields account_number, email | sort account_number;
8585
fetched rows / total rows = 3/3
8686
+----------------+-----------------------+
8787
| account_number | email |
@@ -99,7 +99,7 @@ The example show dedup the consecutive document.
9999

100100
PPL query::
101101

102-
os> source=accounts | dedup gender consecutive=true | fields account_number, gender;
102+
os> source=accounts | dedup gender consecutive=true | fields account_number, gender | sort account_number;
103103
fetched rows / total rows = 3/3
104104
+----------------+--------+
105105
| account_number | gender |

docs/user/ppl/cmd/join.rst

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Example 1: Two indices join
9999

100100
PPL query::
101101

102-
PPL> source = state_country | inner join left=a right=b ON a.name = b.name occupation | stats avg(salary) by span(age, 10) as age_span, b.country;
102+
os> source = state_country | inner join left=a right=b ON a.name = b.name occupation | stats avg(salary) by span(age, 10) as age_span, b.country;
103103
fetched rows / total rows = 5/5
104104
+-------------+----------+-----------+
105105
| avg(salary) | age_span | b.country |
@@ -116,17 +116,8 @@ Example 2: Join with subsearch
116116

117117
PPL query::
118118

119-
PPL> source = state_country as a
120-
| where country = 'USA' OR country = 'England'
121-
| left join ON a.name = b.name [
122-
source = occupation
123-
| where salary > 0
124-
| fields name, country, salary
125-
| sort salary
126-
| head 3
127-
] as b
128-
| stats avg(salary) by span(age, 10) as age_span, b.country;
129-
fetched rows / total rows = 5/5
119+
PPL> source = state_country as a | where country = 'USA' OR country = 'England' | left join ON a.name = b.name [ source = occupation | where salary > 0 | fields name, country, salary | sort salary | head 3 ] as b | stats avg(salary) by span(age, 10) as age_span, b.country;
120+
fetched rows / total rows = 3/3
130121
+-------------+----------+-----------+
131122
| avg(salary) | age_span | b.country |
132123
|-------------+----------+-----------|
@@ -140,32 +131,23 @@ Example 3: Join with field list
140131

141132
PPL query::
142133

143-
PPL> source = state_country
144-
| where country = 'USA' OR country = 'England'
145-
| join type=left overwrite=true name [
146-
source = occupation
147-
| where salary > 0
148-
| fields name, country, salary
149-
| sort salary
150-
| head 3
151-
]
152-
| stats avg(salary) by span(age, 10) as age_span, country;
153-
fetched rows / total rows = 5/5
154-
+-------------+----------+-----------+
155-
| avg(salary) | age_span | country |
156-
|-------------+----------+-----------|
157-
| null | 40 | null |
158-
| 70000.0 | 30 | USA |
159-
| 100000.0 | 70 | England |
160-
+-------------+----------+-----------+
134+
PPL> source = state_country | where country = 'USA' OR country = 'England' | join type=left overwrite=true name [ source = occupation | where salary > 0 | fields name, country, salary | sort salary | head 3 ] | stats avg(salary) by span(age, 10) as age_span, country;
135+
fetched rows / total rows = 3/3
136+
+-------------+----------+---------+
137+
| avg(salary) | age_span | country |
138+
|-------------+----------+---------|
139+
| null | 40 | null |
140+
| 70000.0 | 30 | USA |
141+
| 100000.0 | 70 | England |
142+
+-------------+----------+---------+
161143

162144
Example 4: Join with options
163145
============================
164146

165147
PPL query::
166148

167-
PPL> source = state_country | join type=inner overwrite=false max=1 name occupation | stats avg(salary) by span(age, 10) as age_span, country;
168-
fetched rows / total rows = 5/5
149+
os> source = state_country | join type=inner overwrite=false max=1 name occupation | stats avg(salary) by span(age, 10) as age_span, country;
150+
fetched rows / total rows = 4/4
169151
+-------------+----------+---------+
170152
| avg(salary) | age_span | country |
171153
|-------------+----------+---------|

docs/user/ppl/cmd/rare.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Syntax
1919
============
2020
rare <field-list> [by-clause]
2121

22-
rare <field-list> [rare-options] [by-clause] ``(available from 3.1.0+)``
22+
rare [rare-options] <field-list> [by-clause] ``(available from 3.1.0+)``
2323

2424
* field-list: mandatory. comma-delimited list of field names.
2525
* by-clause: optional. one or more fields to group the results by.
@@ -35,7 +35,7 @@ The example finds least common gender of all the accounts.
3535

3636
PPL query::
3737

38-
os> source=accounts | rare gender;
38+
os> source=accounts | rare showcount=false gender;
3939
fetched rows / total rows = 2/2
4040
+--------+
4141
| gender |
@@ -52,7 +52,7 @@ The example finds least common age of all the accounts group by gender.
5252

5353
PPL query::
5454

55-
os> source=accounts | rare age by gender;
55+
os> source=accounts | rare showcount=false age by gender;
5656
fetched rows / total rows = 4/4
5757
+--------+-----+
5858
| gender | age |

0 commit comments

Comments
 (0)