forked from estuary/flow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_array.flow.yaml
More file actions
54 lines (52 loc) · 1.89 KB
/
set_array.flow.yaml
File metadata and controls
54 lines (52 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
collections:
example/reductions/set-array:
schema:
type: object
reduce: { strategy: merge }
properties:
key: { type: string }
value:
# Sets are always represented as an object.
type: object
reduce:
strategy: set
key: [/0]
# Schema for "add", "intersect", & "remove" properties
# (each a sorted array of [key, sum] 2-tuples):
additionalProperties:
type: array
# Flow requires that all parents of locations with a reduce
# annotation also have one themselves.
# This strategy therefore must (currently) be here, but is ignored.
reduce: { strategy: lastWriteWins }
# Schema for contained [key, sum] 2-tuples:
items:
type: array
items:
- type: string
- type: number
reduce: { strategy: sum }
reduce: { strategy: merge }
required: [key]
key: [/key]
tests:
example/reductions/test/set-operations-as-array:
- ingest:
collection: example/reductions/set-array
documents:
- { key: "key", value: { "add": [["a", 1], ["b", 1], ["c", 1]] } }
- { key: "key", value: { "remove": [["b", 0]] } }
- { key: "key", value: { "add": [["a", 1], ["d", 1]] } }
- verify:
collection: example/reductions/set-array
documents:
- { key: "key", value: { "add": [["a", 2], ["c", 1], ["d", 1]] } }
- ingest:
collection: example/reductions/set-array
documents:
- { key: "key", value: { "intersect": [["a", 0], ["d", 0]] } }
- { key: "key", value: { "add": [["a", 1], ["e", 1]] } }
- verify:
collection: example/reductions/set-array
documents:
- { key: "key", value: { "add": [["a", 3], ["d", 1], ["e", 1]] } }