Skip to content

Commit cf1564b

Browse files
authored
Update doctest code for more consistent runs (#3053)
Signed-off-by: Simeon Widdis <[email protected]>
1 parent 7477fd8 commit cf1564b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2734
-2702
lines changed

docs/user/beyond/partiql.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ Selecting top level for object fields, object fields of array value and nested f
202202

203203
os> SELECT city, accounts, projects FROM people;
204204
fetched rows / total rows = 1/1
205-
+-----------------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------+
206-
| city | accounts | projects |
207-
|-----------------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------|
208-
| {'name': 'Seattle', 'location': {'latitude': 10.5}} | {'id': 1} | [{'name': 'AWS Redshift Spectrum querying'},{'name': 'AWS Redshift security'},{'name': 'AWS Aurora security'}] |
209-
+-----------------------------------------------------+------------+----------------------------------------------------------------------------------------------------------------+
205+
+-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------+
206+
| city | accounts | projects |
207+
|-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------|
208+
| {'name': 'Seattle', 'location': {'latitude': 10.5}} | {'id': 1} | [{'name': 'AWS Redshift Spectrum querying'},{'name': 'AWS Redshift security'},{'name': 'AWS Aurora security'}] |
209+
+-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------+
210210

211211
Example 2: Selecting Deeper Levels
212212
----------------------------------
@@ -215,11 +215,11 @@ Selecting at deeper levels for object fields of regular value returns inner fiel
215215

216216
os> SELECT city.location, city.location.latitude FROM people;
217217
fetched rows / total rows = 1/1
218-
+--------------------+--------------------------+
219-
| city.location | city.location.latitude |
220-
|--------------------+--------------------------|
221-
| {'latitude': 10.5} | 10.5 |
222-
+--------------------+--------------------------+
218+
+--------------------+------------------------+
219+
| city.location | city.location.latitude |
220+
|--------------------+------------------------|
221+
| {'latitude': 10.5} | 10.5 |
222+
+--------------------+------------------------+
223223

224224

225225
For selecting second level for nested fields, please read on and find more details in the following sections.

docs/user/dql/aggregations.rst

+108-108
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ The group by expression could be identifier::
3434

3535
os> SELECT gender, sum(age) FROM accounts GROUP BY gender;
3636
fetched rows / total rows = 2/2
37-
+----------+------------+
38-
| gender | sum(age) |
39-
|----------+------------|
40-
| F | 28 |
41-
| M | 101 |
42-
+----------+------------+
37+
+--------+----------+
38+
| gender | sum(age) |
39+
|--------+----------|
40+
| F | 28 |
41+
| M | 101 |
42+
+--------+----------+
4343

4444

4545
Ordinal
@@ -49,12 +49,12 @@ The group by expression could be ordinal::
4949

5050
os> SELECT gender, sum(age) FROM accounts GROUP BY 1;
5151
fetched rows / total rows = 2/2
52-
+----------+------------+
53-
| gender | sum(age) |
54-
|----------+------------|
55-
| F | 28 |
56-
| M | 101 |
57-
+----------+------------+
52+
+--------+----------+
53+
| gender | sum(age) |
54+
|--------+----------|
55+
| F | 28 |
56+
| M | 101 |
57+
+--------+----------+
5858

5959

6060
Expression
@@ -64,14 +64,14 @@ The group by expression could be expression::
6464

6565
os> SELECT abs(account_number), sum(age) FROM accounts GROUP BY abs(account_number);
6666
fetched rows / total rows = 4/4
67-
+-----------------------+------------+
68-
| abs(account_number) | sum(age) |
69-
|-----------------------+------------|
70-
| 1 | 32 |
71-
| 13 | 28 |
72-
| 18 | 33 |
73-
| 6 | 36 |
74-
+-----------------------+------------+
67+
+---------------------+----------+
68+
| abs(account_number) | sum(age) |
69+
|---------------------+----------|
70+
| 1 | 32 |
71+
| 13 | 28 |
72+
| 18 | 33 |
73+
| 6 | 36 |
74+
+---------------------+----------+
7575

7676

7777
Aggregation
@@ -91,12 +91,12 @@ The aggregation could be used select::
9191

9292
os> SELECT gender, sum(age) FROM accounts GROUP BY gender;
9393
fetched rows / total rows = 2/2
94-
+----------+------------+
95-
| gender | sum(age) |
96-
|----------+------------|
97-
| F | 28 |
98-
| M | 101 |
99-
+----------+------------+
94+
+--------+----------+
95+
| gender | sum(age) |
96+
|--------+----------|
97+
| F | 28 |
98+
| M | 101 |
99+
+--------+----------+
100100

101101
Expression over Aggregation
102102
---------------------------
@@ -105,12 +105,12 @@ The aggregation could be used as arguments of expression::
105105

106106
os> SELECT gender, sum(age) * 2 as sum2 FROM accounts GROUP BY gender;
107107
fetched rows / total rows = 2/2
108-
+----------+--------+
109-
| gender | sum2 |
110-
|----------+--------|
111-
| F | 56 |
112-
| M | 202 |
113-
+----------+--------+
108+
+--------+------+
109+
| gender | sum2 |
110+
|--------+------|
111+
| F | 56 |
112+
| M | 202 |
113+
+--------+------+
114114

115115
Expression as argument of Aggregation
116116
-------------------------------------
@@ -119,12 +119,12 @@ The aggregation could has expression as arguments::
119119

120120
os> SELECT gender, sum(age * 2) as sum2 FROM accounts GROUP BY gender;
121121
fetched rows / total rows = 2/2
122-
+----------+--------+
123-
| gender | sum2 |
124-
|----------+--------|
125-
| F | 56 |
126-
| M | 202 |
127-
+----------+--------+
122+
+--------+------+
123+
| gender | sum2 |
124+
|--------+------|
125+
| F | 56 |
126+
| M | 202 |
127+
+--------+------+
128128

129129
COUNT Aggregations
130130
------------------
@@ -150,12 +150,12 @@ Example::
150150

151151
os> SELECT gender, count(*) as countV FROM accounts GROUP BY gender;
152152
fetched rows / total rows = 2/2
153-
+----------+----------+
154-
| gender | countV |
155-
|----------+----------|
156-
| F | 1 |
157-
| M | 3 |
158-
+----------+----------+
153+
+--------+--------+
154+
| gender | countV |
155+
|--------+--------|
156+
| F | 1 |
157+
| M | 3 |
158+
+--------+--------+
159159

160160
SUM
161161
---
@@ -169,12 +169,12 @@ Example::
169169

170170
os> SELECT gender, sum(age) as sumV FROM accounts GROUP BY gender;
171171
fetched rows / total rows = 2/2
172-
+----------+--------+
173-
| gender | sumV |
174-
|----------+--------|
175-
| F | 28 |
176-
| M | 101 |
177-
+----------+--------+
172+
+--------+------+
173+
| gender | sumV |
174+
|--------+------|
175+
| F | 28 |
176+
| M | 101 |
177+
+--------+------+
178178

179179
AVG
180180
---
@@ -188,12 +188,12 @@ Example::
188188

189189
os> SELECT gender, avg(age) as avgV FROM accounts GROUP BY gender;
190190
fetched rows / total rows = 2/2
191-
+----------+--------------------+
192-
| gender | avgV |
193-
|----------+--------------------|
194-
| F | 28.0 |
195-
| M | 33.666666666666664 |
196-
+----------+--------------------+
191+
+--------+--------------------+
192+
| gender | avgV |
193+
|--------+--------------------|
194+
| F | 28.0 |
195+
| M | 33.666666666666664 |
196+
+--------+--------------------+
197197

198198
MAX
199199
---
@@ -207,11 +207,11 @@ Example::
207207

208208
os> SELECT max(age) as maxV FROM accounts;
209209
fetched rows / total rows = 1/1
210-
+--------+
211-
| maxV |
212-
|--------|
213-
| 36 |
214-
+--------+
210+
+------+
211+
| maxV |
212+
|------|
213+
| 36 |
214+
+------+
215215

216216
MIN
217217
---
@@ -225,11 +225,11 @@ Example::
225225

226226
os> SELECT min(age) as minV FROM accounts;
227227
fetched rows / total rows = 1/1
228-
+--------+
229-
| minV |
230-
|--------|
231-
| 28 |
232-
+--------+
228+
+------+
229+
| minV |
230+
|------|
231+
| 28 |
232+
+------+
233233

234234
VAR_POP
235235
-------
@@ -364,11 +364,11 @@ To get the count of distinct values of a field, you can add a keyword ``DISTINCT
364364

365365
os> SELECT COUNT(DISTINCT gender), COUNT(gender) FROM accounts;
366366
fetched rows / total rows = 1/1
367-
+--------------------------+-----------------+
368-
| COUNT(DISTINCT gender) | COUNT(gender) |
369-
|--------------------------+-----------------|
370-
| 2 | 4 |
371-
+--------------------------+-----------------+
367+
+------------------------+---------------+
368+
| COUNT(DISTINCT gender) | COUNT(gender) |
369+
|------------------------+---------------|
370+
| 2 | 4 |
371+
+------------------------+---------------+
372372

373373
PERCENTILE or PERCENTILE_APPROX
374374
-------------------------------
@@ -382,12 +382,12 @@ Example::
382382

383383
os> SELECT gender, percentile(age, 90) as p90 FROM accounts GROUP BY gender;
384384
fetched rows / total rows = 2/2
385-
+----------+-------+
386-
| gender | p90 |
387-
|----------+-------|
388-
| F | 28 |
389-
| M | 36 |
390-
+----------+-------+
385+
+--------+-----+
386+
| gender | p90 |
387+
|--------+-----|
388+
| F | 28 |
389+
| M | 36 |
390+
+--------+-----+
391391

392392
HAVING Clause
393393
=============
@@ -413,11 +413,11 @@ Here is an example for typical use of ``HAVING`` clause::
413413
... GROUP BY gender
414414
... HAVING sum(age) > 100;
415415
fetched rows / total rows = 1/1
416-
+----------+------------+
417-
| gender | sum(age) |
418-
|----------+------------|
419-
| M | 101 |
420-
+----------+------------+
416+
+--------+----------+
417+
| gender | sum(age) |
418+
|--------+----------|
419+
| M | 101 |
420+
+--------+----------+
421421

422422
Here is another example for using alias in ``HAVING`` condition. Note that if an identifier is ambiguous, for example present both as a select alias and an index field, preference is alias. This means the identifier will be replaced by expression aliased in ``SELECT`` clause::
423423

@@ -427,11 +427,11 @@ Here is another example for using alias in ``HAVING`` condition. Note that if an
427427
... GROUP BY gender
428428
... HAVING s > 100;
429429
fetched rows / total rows = 1/1
430-
+----------+-----+
431-
| gender | s |
432-
|----------+-----|
433-
| M | 101 |
434-
+----------+-----+
430+
+--------+-----+
431+
| gender | s |
432+
|--------+-----|
433+
| M | 101 |
434+
+--------+-----+
435435

436436
HAVING without GROUP BY
437437
-----------------------
@@ -443,11 +443,11 @@ Additionally, a ``HAVING`` clause can work without ``GROUP BY`` clause. This is
443443
... FROM accounts
444444
... HAVING sum(age) > 100;
445445
fetched rows / total rows = 1/1
446-
+------------------------+
447-
| 'Total of age > 100' |
448-
|------------------------|
449-
| Total of age > 100 |
450-
+------------------------+
446+
+----------------------+
447+
| 'Total of age > 100' |
448+
|----------------------|
449+
| Total of age > 100 |
450+
+----------------------+
451451

452452

453453
FILTER Clause
@@ -465,12 +465,12 @@ The group by aggregation with ``FILTER`` clause can set different conditions for
465465

466466
os> SELECT avg(age) FILTER(WHERE balance > 10000) AS filtered, gender FROM accounts GROUP BY gender
467467
fetched rows / total rows = 2/2
468-
+------------+----------+
469-
| filtered | gender |
470-
|------------+----------|
471-
| 28.0 | F |
472-
| 32.0 | M |
473-
+------------+----------+
468+
+----------+--------+
469+
| filtered | gender |
470+
|----------+--------|
471+
| 28.0 | F |
472+
| 32.0 | M |
473+
+----------+--------+
474474

475475
FILTER without GROUP BY
476476
-----------------------
@@ -482,11 +482,11 @@ The ``FILTER`` clause can be used in aggregation functions without GROUP BY as w
482482
... count(*) FILTER(WHERE age > 34) AS filtered
483483
... FROM accounts
484484
fetched rows / total rows = 1/1
485-
+--------------+------------+
486-
| unfiltered | filtered |
487-
|--------------+------------|
488-
| 4 | 1 |
489-
+--------------+------------+
485+
+------------+----------+
486+
| unfiltered | filtered |
487+
|------------+----------|
488+
| 4 | 1 |
489+
+------------+----------+
490490

491491
Distinct count aggregate with FILTER
492492
------------------------------------
@@ -495,9 +495,9 @@ The ``FILTER`` clause is also used in distinct count to do the filtering before
495495

496496
os> SELECT COUNT(DISTINCT firstname) FILTER(WHERE age > 30) AS distinct_count FROM accounts
497497
fetched rows / total rows = 1/1
498-
+------------------+
499-
| distinct_count |
500-
|------------------|
501-
| 3 |
502-
+------------------+
498+
+----------------+
499+
| distinct_count |
500+
|----------------|
501+
| 3 |
502+
+----------------+
503503

0 commit comments

Comments
 (0)