Skip to content

Commit a03b57e

Browse files
committed
Document new duplicate key behavior
Companion to tenzir/tenzir#5445
1 parent 4310128 commit a03b57e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/partials/operators/ParsingOptions.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
import Base from "../ParsingOptionsBase.mdx";
22

3+
### Duplicate Keys
4+
5+
If the parser encounters a duplicate key in an event, it will transparently
6+
upgrade the field to be a list of values instead. If the values are of different
7+
type, conversions to a common type will be attempted, such as to a common number
8+
type. Ultimately values will be stringified if they do not share a common type.
9+
10+
For a simple example, consider this JSON file:
11+
```json title="Example JSON with duplicate key" {2}
12+
{ "key": 7 }
13+
{ "key": 0.0, "key": 1 }
14+
{ "key": 42 }
15+
```
16+
The event with a duplicate key has the respective value upgraded to a list:
17+
```tql {2}
18+
{ key: 7 }
19+
{ key: [0.0, 1.0] }
20+
{ key: 42 }
21+
```
22+
323
### `merge = bool (optional)`
424

525
Merges all incoming events into a single schema\* that converges over time. This
@@ -8,4 +28,6 @@ to huge schemas filled with nulls and imprecise results. Use with caution.
828

929
\*: In selector mode, only events with the same selector are merged.
1030

31+
In merging mode, a repeated key will always overwrite the previous value.
32+
1133
<Base />

0 commit comments

Comments
 (0)