From b6a4ca7fba1aba7004d6b7d9a874892060f10d95 Mon Sep 17 00:00:00 2001 From: Finn Vos Date: Tue, 5 Aug 2025 15:28:21 +0200 Subject: [PATCH] Fix flatten function --- pkg/quickwit/response_parser.go | 1 + pkg/quickwit/response_parser_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/quickwit/response_parser.go b/pkg/quickwit/response_parser.go index 57daa65..d3e0892 100644 --- a/pkg/quickwit/response_parser.go +++ b/pkg/quickwit/response_parser.go @@ -1054,6 +1054,7 @@ func flatten(target map[string]interface{}) map[string]interface{} { if shouldStepInside { currentDepth++ step(v, newKey) + currentDepth-- } else { output[newKey] = value } diff --git a/pkg/quickwit/response_parser_test.go b/pkg/quickwit/response_parser_test.go index bbdf1ea..2fe1c79 100644 --- a/pkg/quickwit/response_parser_test.go +++ b/pkg/quickwit/response_parser_test.go @@ -3166,11 +3166,17 @@ func TestFlatten(t *testing.T) { }, }, }, + "other": map[string]interface{}{ + "nested1": map[string]interface{}{ + "nested2": "def", + }, + }, } flattened := flatten(obj) - require.Len(t, flattened, 1) + require.Len(t, flattened, 2) require.Equal(t, map[string]interface{}{"nested11": map[string]interface{}{"nested12": "abc"}}, flattened["nested0.nested1.nested2.nested3.nested4.nested5.nested6.nested7.nested8.nested9.nested10"]) + require.Equal(t, "def", flattened["other.nested1.nested2"]) }) }