-
Notifications
You must be signed in to change notification settings - Fork 60
/
merge.flow.yaml
44 lines (42 loc) · 1.32 KB
/
merge.flow.yaml
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
collections:
example/reductions/merge:
schema:
type: object
reduce: { strategy: merge }
properties:
key: { type: string }
value:
# Merge only works with types "array" or "object".
# Others will error at build time.
type: [array, object]
reduce: { strategy: merge }
# Deeply merge sub-locations (items or properties) by summing them.
items:
type: number
reduce: { strategy: sum }
additionalProperties:
type: number
reduce: { strategy: sum }
required: [key]
key: [/key]
tests:
example/reductions/test/deep-merge-array:
- ingest:
collection: example/reductions/merge
documents:
- { key: "key", value: [1, 1] }
- { key: "key", value: [2, 2, 2] }
- verify:
collection: example/reductions/merge
documents:
- { key: "key", value: [3, 3, 2] }
example/reductions/test/deep-merge-objects:
- ingest:
collection: example/reductions/merge
documents:
- { key: "key", value: { "a": 1, "b": 1 } }
- { key: "key", value: { "a": 1, "c": 1 } }
- verify:
collection: example/reductions/merge
documents:
- { key: "key", value: { "a": 2, "b": 1, "c": 1 } }