Skip to content

Commit ac9f349

Browse files
committed
Convert more operator examples to mdtest-spq
1 parent 5f67a82 commit ac9f349

File tree

11 files changed

+310
-203
lines changed

11 files changed

+310
-203
lines changed

docs/language/operators/get.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
### Synopsis
66

7-
`get` is a shorthand notation for `from`. See the [from operator](from.md) documentation for details.
7+
`get` is a shorthand notation for `from`. See the [`from` operator](from.md) documentation for details.

docs/language/operators/head.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,37 @@ is not provided, the value of N defaults to `1`.
1717
### Examples
1818

1919
_Grab first two values of arbitrary sequence_
20-
```mdtest-command
21-
echo '1 "foo" [1,2,3]' | super -z -c 'head 2' -
22-
```
23-
24-
```mdtest-output
20+
```mdtest-spq
21+
# spq
22+
head 2
23+
# input
24+
1
25+
"foo"
26+
[1,2,3]
27+
# expected output
2528
1
2629
"foo"
2730
```
2831

2932
_Grab first two values of arbitrary sequence, using a different representation of two_
30-
```mdtest-command
31-
echo '1 "foo" [1,2,3]' | super -z -c 'head 1+1' -
32-
```
33-
34-
```mdtest-output
33+
```mdtest-spq
34+
# spq
35+
head 1+1
36+
# input
37+
1
38+
"foo"
39+
[1,2,3]
40+
# expected output
3541
1
3642
"foo"
3743
```
3844

3945
_Grab the first record of a record sequence_
40-
```mdtest-command
41-
echo '{a:"hello"}{b:"world"}' | super -z -c head -
42-
```
43-
44-
```mdtest-output
46+
```mdtest-spq
47+
# spq
48+
head
49+
# input
50+
{a:"hello"}
51+
# expected output
4552
{a:"hello"}
4653
```

docs/language/operators/join.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
The first `join` syntax shown above was more recently introduced and is in some
2020
ways similar to other languages such as SQL. The second was the original `join`
21-
syntax in SuperPipe. Most joins can be expressed using either syntax. See the
21+
syntax in the language. Most joins can be expressed using either syntax. See the
2222
[join tutorial](../../tutorials/join.md)
2323
for details.
2424

@@ -40,9 +40,13 @@ The available join types are:
4040

4141
For anti join, the `<right-expr>` is undefined and thus cannot be specified.
4242

43-
> Currently, only exact equi-join is supported and join keys must be field
44-
> expressions. A future version of join will have more flexible join
45-
> expressions.
43+
{{% tip "Note" %}}
44+
45+
Currently, only exact equi-join is supported and join keys must be field
46+
expressions. A future version of `join` will have more flexible join
47+
expressions.
48+
49+
{{% /tip %}}
4650

4751
### Examples
4852

docs/language/operators/load.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ echo '{flip:1,result:"heads"} {flip:2,result:"tails"}' |
4444
super db -q create -orderby flip:asc bigflips
4545
super db query -f text '
4646
from :branches
47-
|> yield pool.name + "@" + branch.name
48-
|> sort'
47+
| yield pool.name + "@" + branch.name
48+
| sort'
4949
```
5050

5151
The lake then contains the two pools:
@@ -62,8 +62,8 @@ _Modify some values, load them into the `main` branch of our empty `bigflips` po
6262
```mdtest-command
6363
super db -lake example query '
6464
from coinflips
65-
|> result:=upper(result)
66-
|> load bigflips
65+
| result:=upper(result)
66+
| load bigflips
6767
' > /dev/null
6868
6969
super db -lake example query -z 'from bigflips'
@@ -78,8 +78,8 @@ _Add a filtered subset of records to our `onlytails` branch, while also adding m
7878
```mdtest-command
7979
super db -lake example query '
8080
from coinflips
81-
|> result=="tails"
82-
|> load coinflips@onlytails
81+
| result=="tails"
82+
| load coinflips@onlytails
8383
author "Steve"
8484
message "A subset"
8585
meta "\"Additional metadata\""

docs/language/operators/merge.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@ where the values from the upstream pipeline branches are forwarded based on thes
1717
### Examples
1818

1919
_Copy input to two pipeline branches and merge_
20-
```mdtest-command
21-
echo '1 2' | super -z -c 'fork (=>pass =>pass) |> merge this' -
22-
```
23-
24-
```mdtest-output
20+
```mdtest-spq
21+
# spq
22+
fork (
23+
=>pass
24+
=>pass
25+
)
26+
| merge this
27+
# input
28+
1
29+
2
30+
# expected output
2531
1
2632
1
2733
2

docs/language/operators/over.md

Lines changed: 68 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,94 +31,113 @@ The nested subquery depicted as `<lateral>` is called a [lateral subquery](../la
3131
### Examples
3232

3333
_Over evaluates each expression and emits it_
34-
```mdtest-command
35-
echo null | super -z -c 'over 1,2,"foo"' -
36-
```
37-
38-
```mdtest-output
34+
```mdtest-spq
35+
# spq
36+
over 1,2,"foo"
37+
# input
38+
null
39+
# expected output
3940
1
4041
2
4142
"foo"
4243
```
43-
_The over clause is evaluated once per each input value_
44-
```mdtest-command
45-
echo "null null" | super -z -c 'over 1,2' -
46-
```
4744

48-
```mdtest-output
45+
_The over clause is evaluated once per each input value_
46+
```mdtest-spq
47+
# spq
48+
over 1,2
49+
# input
50+
null
51+
null
52+
# expected output
4953
1
5054
2
5155
1
5256
2
5357
```
54-
_Array elements are enumerated_
55-
```mdtest-command
56-
echo null | super -z -c 'over [1,2],[3,4,5]' -
57-
```
5858

59-
```mdtest-output
59+
_Array elements are enumerated_
60+
```mdtest-spq
61+
# spq
62+
over [1,2],[3,4,5]
63+
# input
64+
null
65+
# expected output
6066
1
6167
2
6268
3
6369
4
6470
5
6571
```
66-
_Over traversing an array_
67-
```mdtest-command
68-
echo '{a:[1,2,3]}' | super -z -c 'over a' -
69-
```
7072

71-
```mdtest-output
73+
_Over traversing an array_
74+
```mdtest-spq
75+
# spq
76+
over a
77+
# input
78+
{a:[1,2,3]}
79+
# expected output
7280
1
7381
2
7482
3
7583
```
76-
_Filter the traversed values_
77-
78-
```mdtest-command
79-
echo '{a:[6,5,4]} {a:[3,2,1]}' | super -z -c 'over a |> this % 2 == 0' -
80-
```
8184

82-
```mdtest-output
85+
_Filter the traversed values_
86+
```mdtest-spq
87+
# spq
88+
over a | this % 2 == 0
89+
# input
90+
{a:[6,5,4]}
91+
{a:[3,2,1]}
92+
# expected output
8393
6
8494
4
8595
2
8696
```
87-
_Aggregate the traversed values_
88-
89-
```mdtest-command
90-
echo '{a:[1,2]} {a:[3,4,5]}' | super -z -c 'over a |> sum(this)' -
91-
```
9297

93-
```mdtest-output
98+
_Aggregate the traversed values_
99+
```mdtest-spq
100+
# spq
101+
over a | sum(this)
102+
# input
103+
{a:[1,2]}
104+
{a:[3,4,5]}
105+
# expected output
94106
15
95107
```
96-
_Aggregate the traversed values in a lateral query_
97-
```mdtest-command
98-
echo '{a:[1,2]} {a:[3,4,5]}' | super -z -c 'over a => ( sum(this) )' -
99-
```
100108

101-
```mdtest-output
109+
_Aggregate the traversed values in a lateral query_
110+
```mdtest-spq
111+
# spq
112+
over a => ( sum(this) )
113+
# input
114+
{a:[1,2]}
115+
{a:[3,4,5]}
116+
# expected output
102117
3
103118
12
104119
```
105-
_Access the outer values in a lateral query_
106-
```mdtest-command
107-
echo '{a:[1,2],s:"foo"} {a:[3,4,5],s:"bar"}' |
108-
super -z -c 'over a with s => (sum(this) |> yield {s,sum:this})' -
109-
```
110120

111-
```mdtest-output
121+
_Access the outer values in a lateral query_
122+
```mdtest-spq
123+
# spq
124+
over a with s => (sum(this) | yield {s,sum:this})
125+
# input
126+
{a:[1,2],s:"foo"}
127+
{a:[3,4,5],s:"bar"}
128+
# expected output
112129
{s:"foo",sum:3}
113130
{s:"bar",sum:12}
114131
```
115-
_Traverse a record by flattening it_
116-
```mdtest-command
117-
echo '{s:"foo",r:{a:1,b:2}} {s:"bar",r:{a:3,b:4}} ' |
118-
super -z -c 'over flatten(r) with s => (yield {s,key:key[0],value})' -
119-
```
120132

121-
```mdtest-output
133+
_Traverse a record by flattening it_
134+
```mdtest-spq
135+
# spq
136+
over flatten(r) with s => (yield {s,key:key[0],value})
137+
# input
138+
{s:"foo",r:{a:1,b:2}}
139+
{s:"bar",r:{a:3,b:4}}
140+
# expected output
122141
{s:"foo",key:"a",value:1}
123142
{s:"foo",key:"b",value:2}
124143
{s:"bar",key:"a",value:3}

docs/language/operators/pass.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,31 @@ with operators that handle multiple branches of the pipeline such as
1616
### Examples
1717

1818
_Copy input to output_
19-
```mdtest-command
20-
echo '1 2 3' | super -z -c pass -
21-
```
22-
23-
```mdtest-output
19+
```mdtest-spq
20+
# spq
21+
pass
22+
# input
23+
1
24+
2
25+
3
26+
# expected output
2427
1
2528
2
2629
3
2730
```
2831

2932
_Copy each input value to three parallel pipeline branches and leave the values unmodified on one of them_
30-
```mdtest-command
31-
echo '"HeLlo, WoRlD!"' | super -z -c '
32-
fork (
33-
=> pass
34-
=> upper(this)
35-
=> lower(this)
36-
) |> sort' -
37-
```
38-
39-
```mdtest-output
33+
```mdtest-spq
34+
# spq
35+
fork (
36+
=> pass
37+
=> upper(this)
38+
=> lower(this)
39+
)
40+
| sort
41+
# input
42+
"HeLlo, WoRlD!"
43+
# expected output
4044
"HELLO, WORLD!"
4145
"HeLlo, WoRlD!"
4246
"hello, world!"

0 commit comments

Comments
 (0)