Skip to content

Commit b3ee986

Browse files
authored
Merge pull request #156 from fiinnnn/main
Fix inconsistent field flattening
2 parents af7f8a4 + b6a4ca7 commit b3ee986

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pkg/quickwit/response_parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ func flatten(target map[string]interface{}) map[string]interface{} {
10541054
if shouldStepInside {
10551055
currentDepth++
10561056
step(v, newKey)
1057+
currentDepth--
10571058
} else {
10581059
output[newKey] = value
10591060
}

pkg/quickwit/response_parser_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3166,11 +3166,17 @@ func TestFlatten(t *testing.T) {
31663166
},
31673167
},
31683168
},
3169+
"other": map[string]interface{}{
3170+
"nested1": map[string]interface{}{
3171+
"nested2": "def",
3172+
},
3173+
},
31693174
}
31703175

31713176
flattened := flatten(obj)
3172-
require.Len(t, flattened, 1)
3177+
require.Len(t, flattened, 2)
31733178
require.Equal(t, map[string]interface{}{"nested11": map[string]interface{}{"nested12": "abc"}}, flattened["nested0.nested1.nested2.nested3.nested4.nested5.nested6.nested7.nested8.nested9.nested10"])
3179+
require.Equal(t, "def", flattened["other.nested1.nested2"])
31743180
})
31753181
}
31763182

0 commit comments

Comments
 (0)